Object Hierarchy:

Object hierarchy for TextView


public class TextView : Container, Implementor, Buildable, Scrollable

You may wish to begin by reading the text widget conceptual overview which gives an overview of all the objects and data types related to the text widget and how they work together.

CSS nodes

├── border.top
├── border.left
├── text
│ ╰── [selection]
├── border.right
├── border.bottom
╰── [window.popup]
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.


Example: TextView:

public class Application : Gtk.Window {
public Application () {
// Prepare Gtk.Window:
this.title = "My Gtk.TextView";
this.window_position = Gtk.WindowPosition.CENTER;
this.destroy.connect (Gtk.main_quit);
this.set_default_size (400, 400);

// Box:
Gtk.Box box = new Gtk.Box (Gtk.Orientation.VERTICAL, 1);
this.add (box);

// A ScrolledWindow:
Gtk.ScrolledWindow scrolled = new Gtk.ScrolledWindow (null, null);
box.pack_start (scrolled, true, true, 0);

// The TextView:
Gtk.TextView view = new Gtk.TextView ();
view.set_wrap_mode (Gtk.WrapMode.WORD);
view.buffer.text = "Lorem Ipsum";
scrolled.add (view);

// A Button:
Gtk.Button button = new Gtk.Button.with_label ("Print content to stdout");
box.pack_start (button, false, true, 0);
button.clicked.connect (() => {
print (view.buffer.text);
print ("\n");

public static int main (string[] args) {
Gtk.init (ref args);

Application app = new Application ();
app.show_all ();
Gtk.main ();
return 0;

valac --pkg gtk+-3.0 Gtk.TextView.vala

Namespace: Gtk
Package: gtk+-3.0



Creation methods:



Inherited Members:

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