Reputation: 14505
I have a GTK TextView
and I need to put selected text into a string, how can I do that?
There is event SelectionGet, but it doesn't seem to work. (Never triggered)
Upvotes: 0
Views: 1062
Reputation: 14505
public string Selection
{
get
{
Gtk.TextIter A;
Gtk.TextIter B;
if (textView.Buffer.GetSelectionBounds(out A, out B))
{
return textView.Buffer.GetText(A, B, true);
}
// return null when there is no selection
return null;
}
}
Upvotes: 1