Skip to main content

EditableExt

Trait EditableExt 

Source
pub trait EditableExt: IsA<Editable> + 'static {
Show 13 methods // Provided methods fn copy_clipboard(&self) { ... } fn cut_clipboard(&self) { ... } fn delete_selection(&self) { ... } fn delete_text(&self, start_pos: i32, end_pos: i32) { ... } fn chars(&self, start_pos: i32, end_pos: i32) -> Option<GString> { ... } fn is_editable(&self) -> bool { ... } fn position(&self) -> i32 { ... } fn selection_bounds(&self) -> Option<(i32, i32)> { ... } fn insert_text(&self, new_text: &str, position: &mut i32) { ... } fn paste_clipboard(&self) { ... } fn select_region(&self, start_pos: i32, end_pos: i32) { ... } fn set_editable(&self, is_editable: bool) { ... } fn set_position(&self, position: i32) { ... }
}
Expand description

Trait containing all Editable methods.

§Implementors

Editable, Entry, SearchEntry, SpinButton

Provided Methods§

Source

fn copy_clipboard(&self)

Copies the contents of the currently selected content in the editable and puts it on the clipboard.

Source

fn cut_clipboard(&self)

Removes the contents of the currently selected content in the editable and puts it on the clipboard.

Source

fn delete_selection(&self)

Deletes the currently selected text of the editable. This call doesn’t do anything if there is no selected text.

Source

fn delete_text(&self, start_pos: i32, end_pos: i32)

Deletes a sequence of characters. 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 characters deleted are those from start_pos to the end of the text.

Note that the positions are specified in characters, not bytes.

§start_pos

start position

§end_pos

end position

Source

fn chars(&self, start_pos: i32, end_pos: i32) -> Option<GString>

Retrieves a sequence of characters. 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 characters retrieved are those characters from start_pos to the end of the text.

Note that positions are specified in characters, not bytes.

§start_pos

start of text

§end_pos

end of text

§Returns

a pointer to the contents of the widget as a string. This string is allocated by the Editable implementation and should be freed by the caller.

Source

fn is_editable(&self) -> bool

Retrieves whether self is editable. See set_editable().

§Returns

true if self is editable.

Source

fn position(&self) -> i32

Retrieves the current position of the cursor relative to the start of the content of the editable.

Note that this position is in characters, not in bytes.

§Returns

the cursor position

Source

fn selection_bounds(&self) -> Option<(i32, i32)>

Retrieves the selection bound of the editable. 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.

§Returns

true if an area is selected, false otherwise

§start_pos

location to store the starting position, or None

§end_pos

location to store the end position, or None

Source

fn insert_text(&self, new_text: &str, position: &mut i32)

Inserts new_text_length bytes of new_text into the contents of the widget, at position position.

Note that the position is in characters, not in bytes. The function updates position to point after the newly inserted text.

§new_text

the text to append

§new_text_length

the length of the text in bytes, or -1

§Returns
§position

location of the position text will be inserted at

Source

fn paste_clipboard(&self)

Pastes the content of the clipboard to the current position of the cursor in the editable.

Source

fn select_region(&self, start_pos: i32, end_pos: i32)

Selects a region of text. 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 characters selected are those characters from start_pos to the end of the text.

Note that positions are specified in characters, not bytes.

§start_pos

start of region

§end_pos

end of region

Source

fn set_editable(&self, is_editable: bool)

Determines if the user can edit the text in the editable widget or not.

§is_editable

true if the user is allowed to edit the text in the widget

Source

fn set_position(&self, position: i32)

Sets the cursor position in the editable to the given value.

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.

§position

the position of the cursor

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§