pub trait EditableExt:
IsA<Editable>
+ Sealed
+ 'static {
Show 35 methods
// Provided methods
fn delegate_get_accessible_platform_state(
&self,
state: AccessiblePlatformState,
) -> bool { ... }
fn delete_selection(&self) { ... }
fn delete_text(&self, start_pos: i32, end_pos: i32) { ... }
fn finish_delegate(&self) { ... }
fn alignment(&self) -> f32 { ... }
fn chars(&self, start_pos: i32, end_pos: i32) -> GString { ... }
fn delegate(&self) -> Option<Editable> { ... }
fn is_editable(&self) -> bool { ... }
fn enables_undo(&self) -> bool { ... }
fn max_width_chars(&self) -> i32 { ... }
fn position(&self) -> i32 { ... }
fn selection_bounds(&self) -> Option<(i32, i32)> { ... }
fn text(&self) -> GString { ... }
fn width_chars(&self) -> i32 { ... }
fn init_delegate(&self) { ... }
fn insert_text(&self, text: &str, position: &mut i32) { ... }
fn select_region(&self, start_pos: i32, end_pos: i32) { ... }
fn set_alignment(&self, xalign: f32) { ... }
fn set_editable(&self, is_editable: bool) { ... }
fn set_enable_undo(&self, enable_undo: bool) { ... }
fn set_max_width_chars(&self, n_chars: i32) { ... }
fn set_position(&self, position: i32) { ... }
fn set_text(&self, text: &str) { ... }
fn set_width_chars(&self, n_chars: i32) { ... }
fn selection_bound(&self) -> i32 { ... }
fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { ... }
fn connect_delete_text<F: Fn(&Self, i32, i32) + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_cursor_position_notify<F: Fn(&Self) + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_editable_notify<F: Fn(&Self) + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_enable_undo_notify<F: Fn(&Self) + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_max_width_chars_notify<F: Fn(&Self) + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_selection_bound_notify<F: Fn(&Self) + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_text_notify<F: Fn(&Self) + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_width_chars_notify<F: Fn(&Self) + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_xalign_notify<F: Fn(&Self) + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
}
Expand description
Trait containing all Editable
methods.
§Implementors
EditableLabel
, Editable
, Entry
, PasswordEntry
, SearchEntry
, SpinButton
, Text
Provided Methods§
Sourcefn delegate_get_accessible_platform_state(
&self,
state: AccessiblePlatformState,
) -> bool
Available on crate feature v4_10
only.
fn delegate_get_accessible_platform_state( &self, state: AccessiblePlatformState, ) -> bool
v4_10
only.Retrieves the accessible platform state from the editable delegate.
This is an helper function to retrieve the accessible state for
Editable
interface implementations using a delegate pattern.
You should call this function in your editable widget implementation
of the vfunc::Gtk::Accessible::get_platform_state
virtual function, for
instance:
⚠️ The following code is in c ⚠️
static void
accessible_interface_init (GtkAccessibleInterface *iface)
{
iface->get_platform_state = your_editable_get_accessible_platform_state;
}
static gboolean
your_editable_get_accessible_platform_state (GtkAccessible *accessible,
GtkAccessiblePlatformState state)
{
return gtk_editable_delegate_get_accessible_platform_state (GTK_EDITABLE (accessible), state);
}
Note that the widget which is the delegate must be a direct child of
this widget, otherwise your implementation of vfunc::Gtk::Accessible::get_platform_state
might not even be called, as the platform change will originate from
the parent of the delegate, and, as a result, will not work properly.
So, if you can’t ensure the direct child condition, you should give the
delegate the AccessibleRole::TextBox
role, or you can
change your tree to allow this function to work.
§state
what kind of accessible state to retrieve
§Returns
the accessible platform state of the delegate
Sourcefn delete_selection(&self)
fn delete_selection(&self)
Deletes the currently selected text of the editable.
This call doesn’t do anything if there is no selected text.
Sourcefn delete_text(&self, start_pos: i32, end_pos: i32)
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
Sourcefn finish_delegate(&self)
fn finish_delegate(&self)
Undoes the setup done by init_delegate()
.
This is a helper function that should be called from dispose, before removing the delegate object.
Sourcefn chars(&self, start_pos: i32, end_pos: i32) -> GString
fn chars(&self, start_pos: i32, end_pos: i32) -> 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.
Sourcefn is_editable(&self) -> bool
fn is_editable(&self) -> bool
Sourcefn enables_undo(&self) -> bool
fn enables_undo(&self) -> bool
Sourcefn max_width_chars(&self) -> i32
fn max_width_chars(&self) -> i32
Retrieves the desired maximum width of @self, in characters.
§Returns
the maximum width of the entry, in characters
Sourcefn position(&self) -> i32
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
Sourcefn selection_bounds(&self) -> Option<(i32, i32)>
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 there is a non-empty selection, false
otherwise
§start_pos
location to store the starting position
§end_pos
location to store the end position
Sourcefn text(&self) -> GString
fn text(&self) -> GString
Retrieves the contents of @self.
The returned string is owned by GTK and must not be modified or freed.
§Returns
a pointer to the contents of the editable
Sourcefn width_chars(&self) -> i32
fn width_chars(&self) -> i32
Gets the number of characters of space reserved for the contents of the editable.
§Returns
number of chars to request space for, or negative if unset
Sourcefn init_delegate(&self)
fn init_delegate(&self)
Sourcefn insert_text(&self, text: &str, position: &mut i32)
fn insert_text(&self, text: &str, position: &mut i32)
Inserts @length bytes of @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.
§text
the text to insert
§length
the length of the text in bytes, or -1
§position
location of the position text will be inserted at
Sourcefn select_region(&self, start_pos: i32, end_pos: i32)
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
Sourcefn set_alignment(&self, xalign: f32)
fn set_alignment(&self, xalign: f32)
Sets the alignment for the contents of the editable.
This controls the horizontal positioning of the contents when the displayed text is shorter than the width of the editable.
§xalign
The horizontal alignment, from 0 (left) to 1 (right). Reversed for RTL layouts
Sourcefn set_editable(&self, is_editable: bool)
fn set_editable(&self, is_editable: bool)
Sourcefn set_enable_undo(&self, enable_undo: bool)
fn set_enable_undo(&self, enable_undo: bool)
If enabled, changes to @self will be saved for undo/redo actions.
This results in an additional copy of text changes and are not
stored in secure memory. As such, undo is forcefully disabled
when visibility
is set to false
.
§enable_undo
if undo/redo should be enabled
Sourcefn set_max_width_chars(&self, n_chars: i32)
fn set_max_width_chars(&self, n_chars: i32)
Sets the desired maximum width in characters of @self.
§n_chars
the new desired maximum width, in characters
Sourcefn set_position(&self, position: i32)
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
Sourcefn set_text(&self, text: &str)
fn set_text(&self, text: &str)
Sets the text in the editable to the given value.
This is replacing the current contents.
§text
the text to set
Sourcefn set_width_chars(&self, n_chars: i32)
fn set_width_chars(&self, n_chars: i32)
Changes the size request of the editable to be about the right size for @n_chars characters.
Note that it changes the size request, the size can still be affected by how you pack the widget into containers. If @n_chars is -1, the size reverts to the default size.
§n_chars
width in chars
Sourcefn selection_bound(&self) -> i32
fn selection_bound(&self) -> i32
The position of the opposite end of the selection from the cursor in chars.
Sourcefn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
Emitted at the end of a single user-visible operation on the contents.
E.g., a paste operation that replaces the contents of the selection will cause only one signal emission (even though it is implemented by first deleting the selection, then inserting the new content, and may cause multiple ::notify::text signals to be emitted).
Sourcefn connect_delete_text<F: Fn(&Self, i32, i32) + 'static>(
&self,
f: F,
) -> SignalHandlerId
fn connect_delete_text<F: Fn(&Self, i32, i32) + 'static>( &self, f: F, ) -> SignalHandlerId
Emitted when text is deleted from the widget by the user.
The default handler for this signal will normally be responsible for deleting the text, so by connecting to this signal and then stopping the signal with g_signal_stop_emission(), it is possible to modify the range of deleted text, or prevent it from being deleted entirely.
The @start_pos and @end_pos parameters are interpreted as for
delete_text()
.
§start_pos
the starting position
§end_pos
the end position
fn connect_cursor_position_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId
fn connect_editable_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId
fn connect_enable_undo_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId
fn connect_max_width_chars_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId
fn connect_selection_bound_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId
fn connect_text_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
fn connect_width_chars_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId
fn connect_xalign_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.