Interface for text-editing widgets
Class GtkEditable
GtkEditable is implemented by GtkEntry, GtkText, GtkOldEditable and GtkSpinButton.
The GtkEditable interface is an interface which should be implemented by text editing widgets, such as GtkEntry and GtkText. It contains functions for generically manipulating an editable widget, a large number of action signals used for key bindings, and several signals that an application can connect to to modify the behavior of a widget.
As an example of the latter usage, by connecting the following handler to "insert_text", an application can convert all entry into a widget into uppercase.
Methods | |
copy_clipboard | Copies the contents of the currently selected content in the editable and puts it on the clipboard. |
cut_clipboard | Removes the contents of the currently selected content in the editable and puts it on the clipboard. |
delete_selection | Deletes the currently selected text of the editable. This call doesn't do anything if there is no selected text. |
delete_text | Deletes a sequence of characters. |
get_chars | Retrieves a sequence of characters. |
get_editable | Retrieves whether editable is editable. |
get_position | Retrieves the current position of the cursor relative to the start of the content of the editable. |
get_selection_bounds | Retrieves the selection bound of the editable. |
insert_text | Inserts new_text into the contents of the widget, at position position. |
paste_clipboard | Pastes the content of the clipboard to the current position of the cursor in the editable. |
select_region | Selects a region of text. |
set_editable | Determines if the user can edit the text in the editable widget or not. |
set_position | Sets the cursor position in the editable to the given value. |
Copies the contents of the currently selected content in the editable and puts it on the clipboard.
GtkEditable.copy_clipboard()
Removes the contents of the currently selected content in the editable and puts it on the clipboard.
GtkEditable.cut_clipboard()
Deletes the currently selected text of the editable. This call doesn't do anything if there is no selected text.
GtkEditable.delete_selection()
Deletes a sequence of characters.
GtkEditable.delete_text( start_pos, end_pos )
start_pos | start of text |
end_pos | end of text |
The characters that are deleted are those characters at positions from start_pos up to, but not including end_pos. If end_pos is negative, then the the characters deleted are those from start_pos to the end of the text.
Note that the positions are specified in characters, not bytes.
Retrieves a sequence of characters.
GtkEditable.get_chars( [start_pos],[end_pos] )
start_pos | start of text (default 0) |
end_pos | end of text (default -1) |
Return | contents of the widget as a string. |
The characters that are retrieved are those characters at positions from start_pos up to, but not including end_pos. If end_pos is negative, then the the characters retrieved are those characters from start_pos to the end of the text.
Note that positions are specified in characters, not bytes.
Retrieves whether editable is editable.
GtkEditable.get_editable()
Return | TRUE if editable is editable. |
Retrieves the current position of the cursor relative to the start of the content of the editable.
GtkEditable.get_position()
Return | the cursor position |
Note that this position is in characters, not in bytes.
Retrieves the selection bound of the editable.
GtkEditable.get_selection_bounds()
Return | [ result (boolean), start_pos, end_pos ]. Result is true if an area is selected, false otherwise. |
start_pos will be filled with the start of the selection and end_pos with end. If no text was selected both will be identical and FALSE will be returned.
Note that positions are specified in characters, not bytes.
Inserts new_text into the contents of the widget, at position position.
GtkEditable.insert_text( new_text, [position] )
new_text | the text to append |
position | location of the position text will be inserted at. (default 0) |
Return | position |
Note that the position is in characters, not in bytes. The function updates position to point after the newly inserted text.
Pastes the content of the clipboard to the current position of the cursor in the editable.
GtkEditable.paste_clipboard()
Selects a region of text.
GtkEditable.select_region( start_pos, end_pos )
start_pos | start of region |
end_pos | end of region |
The characters that are selected are those characters at positions from start_pos up to, but not including end_pos. If end_pos is negative, then the the characters selected are those characters from start_pos to the end of the text.
Note that positions are specified in characters, not bytes.
Determines if the user can edit the text in the editable widget or not.
GtkEditable.set_editable( is_editable )
is_editable | true if the user is allowed to edit the text in the widget |
Sets the cursor position in the editable to the given value.
GtkEditable.set_position( position )
position | the position of the cursor |
The cursor is displayed before the character with the given (base 0) index in the contents of the editable. The value must be less than or equal to the number of characters in the editable. A value of -1 indicates that the position should be set after the last character of the editable. Note that position is in characters, not in bytes.