Object Hierarchy:

Gtk.TextView Gtk.TextView Gtk.TextView Gtk.Container Gtk.Container Gtk.Container->Gtk.TextView Gtk.Widget Gtk.Widget Gtk.Widget->Gtk.Container GLib.InitiallyUnowned GLib.InitiallyUnowned GLib.InitiallyUnowned->Gtk.Widget GLib.Object GLib.Object GLib.Object->GLib.InitiallyUnowned Atk.Implementor Atk.Implementor Atk.Implementor->Gtk.TextView Atk.Implementor->Gtk.Container Atk.Implementor->Gtk.Widget Gtk.Buildable Gtk.Buildable Gtk.Buildable->Gtk.TextView Gtk.Buildable->Gtk.Container Gtk.Buildable->Gtk.Widget Gtk.Scrollable Gtk.Scrollable Gtk.Scrollable->Gtk.TextView


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

You may wish to begin by reading the [text widget conceptual overview](TextWidget.

html) 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