Gtk2::Editable(3)
π Gtk2::Editable β the wrapper for GtkEditable π
okay so bestie, welcome to Gtk2::Editable, the Perl wrapper for GtkEditable. it's the little interface that makes text-entry-ish widgets actually editable β typing, selecting, clipboard chaos, the whole vibe. this page was part of the User Contributed Perl Documentation and honestly? she ate. π
πΈ HIERARCHY πΈ
so here's where she sits in the family tree, no cap:
Glib::Interface
+----Gtk2::Editable
it's giving interface energy, which is correct, because she is one. β¨
β¨ METHODS β¨
okay bestie, here's the whole toolbox. every single one. don't skip, iykyk.
string = $editable->get_chars ($start_pos, $end_pos)β grab the text between two spots. takes:$start_pos(integer)$end_pos(integer)
$editable->copy_clipboardβ copy the current selection to the clipboard. slay. π$editable->cut_clipboardβ cut the current selection to the clipboard. gone but not forgotten. βοΈ$editable->delete_selectionβ just delete the selection, no clipboard involvement. bye bestie π$editable->delete_text ($start_pos, $end_pos)β delete a range of text. takes:$start_pos(integer)$end_pos(integer)
boolean = $editable->get_editableβ is she editable or not? returns a boolean, so true/false vibes only.$editable->set_editable ($is_editable)β toggle whether this thing is editable at all. takes:$is_editable(boolean)
new_position = $editable->insert_text (new_text, position)β shove some text in at a position and get the new position back. takes:$new_text(string)...(list)
$editable->paste_clipboardβ paste whatever's on the clipboard. iconic. π₯integer = $editable->get_positionβ returns the current cursor position as an integer.$editable->set_position ($position)β move the cursor. takes:$position(integer)
$editable->select_region ($start, $end)β highlight a region. takes:$start(integer)$end(integer)
(start, end) = $editable->get_selection_boundsβ Returns integers,startandend. that's the whole thing, periodt.
π SIGNALS π
the signals she emits, listed exactly:
changed(Gtk2::Editable)delete-text(Gtk2::Editable, integer, integer)insert-text(Gtk2::Editable, string, integer, gpointer)
π
the insert-text signal can change stuff π
okay so this is the fun part: The insert-text signal handler can optionally alter the text to be inserted. It may:
- Return no values for no change. Be sure to end with an empty
return.
sub my_insert_text_handler {
my ($widget, $text, $len, $pos, $userdata) = @_;
print "inserting '$text' at char position '$pos'\n";
return; # no values
}
- Return two values
($text, $pos)which are the new text and character position.
sub my_insert_text_handler {
my ($widget, $text, $len, $pos, $userdata) = @_;
return (uc($text), $pos); # force to upper case
}
- Return no values and modify the text in
$_[1]and/or position in$_[3]. For example,
sub my_insert_text_handler {
$_[1] = uc($_[1]); # force to upper case
$_[3] = 0; # force position to the start
return; # no values
}
π¨ bestie, heads up, this one's important: Note that currently in a Perl subclass of aGtk2::Editablewidget, a class closure (ie. class default signal handler) forinsert-textdoes not work this way. It instead sees the C level($text, $len, $pos_pointer), where$pos_pointeris a machine address and cannot be used easily. Hopefully this will change in the future. Asignal_chain_from_overriddenwith the args as passed works, but for anything else the suggestion is to use asignal_connectinstead.
π SEE ALSO π
go read these too, fr fr:
Gtk2Glib::Interface
π COPYRIGHT π
Copyright (C) 2003-2011 by the gtk2-perl team.
This software is licensed under the LGPL. See Gtk2 for a full notice.
and that's the whole page, bestie π written up for perl v5.42.0, dated 2025-07-25, from the Gtk2::Editable(3) manual. go forth and edit text responsibly. π¦β¨π
π¦ where this page comes from
- fedora 43: perl-Gtk2 1.24993-23.fc43 Β· LicenseRef-Callaway-LGPLv2+
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms