TextView


Object Hierarchy:

Object hierarchy for TextView

Description:

[ CCode ( type_id = "gtk_text_view_get_type ()" ) ]
public class TextView : Container, Implementor, Buildable, Scrollable

Displays the contents of a [class@Gtk.

TextBuffer].

<picture> <source srcset="multiline-text-dark.png" media="(prefers-color-scheme: dark)"> <img alt="An example GtkTextView" src="multiline-text.png"> </picture>

You may wish to begin by reading the [conceptual overview](section-text-widget.html), which gives an overview of all the objects and data types related to the text widget and how they work together.

Shortcuts and Gestures

`GtkTextView` supports the following keyboard shortcuts:

  • <kbd>Shift</kbd>+<kbd>F10</kbd> or <kbd>Menu</kbd> opens the context menu.
  • <kbd>Ctrl</kbd>+<kbd>Z</kbd> undoes the last modification.
  • <kbd>Ctrl</kbd>+<kbd>Y</kbd> or <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>Z</kbd > redoes the last undone modification.
  • <kbd>Clear</kbd> clears the content.

Additionally, the following signals have default keybindings:

  • [signal@Gtk.TextView:GtkTextView:backspace]
  • [signal@Gtk.TextView:GtkTextView:copy-clipboard]
  • [signal@Gtk.TextView:GtkTextView:cut-clipboard]
  • [signal@Gtk.TextView:GtkTextView:delete-from-cursor]
  • [signal@Gtk.TextView:GtkTextView:insert-emoji]
  • [signal@Gtk.TextView:GtkTextView:move-cursor]
  • [signal@Gtk.TextView:GtkTextView:paste-clipboard]
  • [signal@Gtk.TextView:GtkTextView:select-all]
  • [signal@Gtk.TextView:GtkTextView:toggle-cursor-visible]
  • [signal@Gtk.TextView:GtkTextView:toggle-overwrite]

Actions

`GtkTextView` defines a set of built-in actions:

  • `clipboard.copy` copies the contents to the clipboard.
  • `clipboard.cut` copies the contents to the clipboard and deletes it from the widget.
  • `clipboard.paste` inserts the contents of the clipboard into the widget.
  • `menu.popup` opens the context menu.
  • `misc.insert-emoji` opens the Emoji chooser.
  • `selection.delete` deletes the current selection.
  • `selection.select-all` selects all of the widgets content.
  • `text.redo` redoes the last change to the contents.
  • `text.undo` undoes the last change to the contents.
  • `text.clear` clears the content.

CSS nodes

``` textview.view ├── border.top ├── border.left ├── text │ ├── [preedit.whole.prediction .spelling-error] │ ╰── [selection] ├── border.right ├── border.bottom ╰── [window.popup] ```

`GtkTextView` has a main css node with name textview and style class .view, and subnodes for each of the border windows, and the main text area, with names border and text, respectively. The border nodes each get one of the style classes .left, .right, .top or .bottom.

A node representing the selection will appear below the text node.

If a context menu is opened, the window node will appear as a subnode of the main node.

If using an input method with a pre-edit buffer, this string will be styled with a `preedit` subnode of the `text` node. the different style classes express the possible roles of a piece of text in the pre-edit buffer:

  • `.whole` denotes the parts of the pre-edit buffer without a special role
  • `.selection`, `.prefix` and `.suffix` style classes will be used to highlight the specific portions of the pre-edit buffer being edited and its surroundings
  • `.prediction` will be used for parts of the pre-edit buffer not typed by the user (e.g. autocompletion)
  • `.spelling-error` and `.compose-error` will be respectively used to indicate errors in spelling or character composition (e.g. non-existent transliterations).

Accessibility

`GtkTextView` uses the [enum@Gtk.AccessibleRole.text_box] role.


Namespace: Gtk
Package: gtk+-3.0

Content:

Properties:

Creation methods:

Methods:

Signals:

Inherited Members:

All known members inherited from class Gtk.Widget
All known members inherited from interface Atk.Implementor