Struct gtk4::Entry

source · []
#[repr(transparent)]
pub struct Entry { /* private fields */ }
Expand description

Entry is a single line text entry widget.

An example GtkEntry

A fairly large set of key bindings are supported by default. If the entered text is longer than the allocation of the widget, the widget will scroll so that the cursor position is visible.

When using an entry for passwords and other sensitive information, it can be put into “password mode” using EntryExt::set_visibility(). In this mode, entered text is displayed using a “invisible” character. By default, GTK picks the best invisible character that is available in the current font, but it can be changed with EntryExt::set_invisible_char().

Entry has the ability to display progress or activity information behind the text. To make an entry display such information, use EntryExt::set_progress_fraction() or EntryExt::set_progress_pulse_step().

Additionally, Entry can show icons at either side of the entry. These icons can be activatable by clicking, can be set up as drag source and can have tooltips. To add an icon, use EntryExt::set_icon_from_gicon() or one of the various other functions that set an icon from an icon name or a paintable. To trigger an action when the user clicks an icon, connect to the signal::Entry::icon-press signal. To allow DND operations from an icon, use EntryExt::set_icon_drag_source(). To set a tooltip on an icon, use EntryExt::set_icon_tooltip_text() or the corresponding function for markup.

Note that functionality or information that is only available by clicking on an icon in an entry may not be accessible at all to users which are not able to use a mouse or other pointing device. It is therefore recommended that any such functionality should also be available by other means, e.g. via the context menu of the entry.

CSS nodes

entry[.flat][.warning][.error]
├── text[.readonly]
├── image.left
├── image.right
╰── [progress[.pulse]]

Entry has a main node with the name entry. Depending on the properties of the entry, the style classes .read-only and .flat may appear. The style classes .warning and .error may also be used with entries.

When the entry shows icons, it adds subnodes with the name image and the style class .left or .right, depending on where the icon appears.

When the entry shows progress, it adds a subnode with the name progress. The node has the style class .pulse when the shown progress is pulsing.

For all the subnodes added to the text node in various situations, see Text.

GtkEntry as GtkBuildable

The Entry implementation of the Buildable interface supports a custom element, which supports any number of elements. The element has attributes named “name“, “value“, “start“ and “end“ and allows you to specify PangoAttribute values for this label.

An example of a UI definition fragment specifying Pango attributes:

<object class="GtkEntry">
  <attributes>
    <attribute name="weight" value="PANGO_WEIGHT_BOLD"/>
    <attribute name="background" value="red" start="5" end="10"/>
  </attributes>
</object>

The start and end attributes specify the range of characters to which the Pango attribute applies. If start and end are not specified, the attribute is applied to the whole text. Note that specifying ranges does not make much sense with translatable attributes. Use markup embedded in the translatable content instead.

Accessibility

Entry uses the AccessibleRole::TextBox role.

Implements

EntryExt, WidgetExt, glib::ObjectExt, AccessibleExt, BuildableExt, ConstraintTargetExt, CellEditableExt, EditableExt, EntryExtManual, WidgetExtManual, AccessibleExtManual, EditableExtManual

Implementations

source

impl Entry

Creates a new entry.

Returns

a new Entry.

Creates a new entry with the specified text buffer.

buffer

The buffer to use for the new Entry.

Returns

a new Entry

Creates a new builder-pattern struct instance to construct Entry objects.

This method returns an instance of EntryBuilder which can be used to create Entry objects.

Trait Implementations

source

impl Clone for Entry

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

source

impl Debug for Entry

Formats the value using the given formatter. Read more

source

impl Default for Entry

Returns the “default value” for a type. Read more

source

impl Display for Entry

Formats the value using the given formatter. Read more

source

impl Hash for Entry

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

source

impl<T: EntryImpl> IsSubclassable<T> for Entry

Override the virtual methods of this class for the given subclass and do other class initialization. Read more

Instance specific initialization. Read more

source

impl Ord for Entry

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

source

impl ParentClassIs for Entry

source

impl<OT: ObjectType> PartialEq<OT> for Entry

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

source

impl<OT: ObjectType> PartialOrd<OT> for Entry

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

source

impl StaticType for Entry

Returns the type identifier of Self.

source

impl Eq for Entry

source

impl IsA<Accessible> for Entry

source

impl IsA<Buildable> for Entry

source

impl IsA<CellEditable> for Entry

source

impl IsA<ConstraintTarget> for Entry

source

impl IsA<Editable> for Entry

source

impl IsA<Widget> for Entry

Auto Trait Implementations

impl RefUnwindSafe for Entry

impl !Send for Entry

impl !Sync for Entry

impl Unpin for Entry

impl UnwindSafe for Entry

Blanket Implementations

source

impl<O> AccessibleExtManual for O where
    O: IsA<Accessible>, 

Updates an array of accessible properties. Read more

Updates an array of accessible relations. Read more

Updates an array of accessible states. Read more

source

impl<T> Any for T where
    T: 'static + ?Sized

Gets the TypeId of self. Read more

source

impl<T> Borrow<T> for T where
    T: ?Sized

Immutably borrows from an owned value. Read more

source

impl<T> BorrowMut<T> for T where
    T: ?Sized

Mutably borrows from an owned value. Read more

source

impl<T> Cast for T where
    T: ObjectType

Upcasts an object to a superclass or interface T. Read more

Upcasts an object to a reference of its superclass or interface T. Read more

Tries to downcast to a subclass or interface implementor T. Read more

Tries to downcast to a reference of its subclass or interface implementor T. Read more

Tries to cast to an object of type T. This handles upcasting, downcasting and casting between interface and interface implementors. All checks are performed at runtime, while downcast and upcast will do many checks at compile-time already. Read more

Tries to cast to reference to an object of type T. This handles upcasting, downcasting and casting between interface and interface implementors. All checks are performed at runtime, while downcast and upcast will do many checks at compile-time already. Read more

Casts to T unconditionally. Read more

Casts to &T unconditionally. Read more

source

impl<T> From<T> for T

Returns the argument unchanged.

source

impl<T, U> Into<U> for T where
    U: From<T>, 

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source

impl<U> IsSubclassableExt for U where
    U: IsClass + ParentClassIs

source

impl<T> ObjectExt for T where
    T: ObjectType

Returns true if the object is an instance of (can be cast to) T.

Returns the type of the object.

Returns the ObjectClass of the object. Read more

Returns the class of the object.

Returns the class of the object in the given type T. Read more

Returns the interface T of the object. Read more

Similar to Self::set_property but fails instead of panicking.

Sets the property property_name of the object to value value. Read more

Similar to Self::set_property but fails instead of panicking.

Sets the property property_name of the object to value value. Read more

Similar to Self::set_properties but fails instead of panicking.

Sets multiple properties of the object at once. Read more

Similar to Self::set_properties_from_value but fails instead of panicking.

Sets multiple properties of the object at once. Read more

Similar to Self::property but fails instead of panicking.

Gets the property property_name of the object and cast it to the type V. Read more

Similar to Self::property_value but fails instead of panicking.

Gets the property property_name of the object. Read more

Check if the object has a property property_name of the given type_. Read more

Get the type of the property property_name of this object. Read more

Get the ParamSpec of the property property_name of this object.

Return all ParamSpec of the properties of this object.

Freeze all property notifications until the return guard object is dropped. Read more

Set arbitrary data on this object with the given key. Read more

Return previously set arbitrary data of this object with the given key. Read more

Retrieve previously set arbitrary data of this object with the given key. Read more

Set arbitrary data on this object with the given key. Read more

Return previously set arbitrary data of this object with the given key. Read more

Retrieve previously set arbitrary data of this object with the given key. Read more

Block a given signal handler. Read more

Unblock a given signal handler.

Stop emission of the currently emitted signal.

Stop emission of the currently emitted signal by the (possibly detailed) signal name.

Similar to Self::connect but fails instead of panicking.

Connect to the signal signal_name on this object. Read more

Similar to Self::connect_id but fails instead of panicking.

Connect to the signal signal_id on this object. Read more

Similar to Self::connect_local but fails instead of panicking.

Connect to the signal signal_name on this object. Read more

Similar to Self::connect_local_id but fails instead of panicking.

Connect to the signal signal_id on this object. Read more

Similar to Self::connect_unsafe but fails instead of panicking.

Connect to the signal signal_name on this object. Read more

Similar to Self::connect_unsafe_id but fails instead of panicking.

Similar to Self::connect_closure but fails instead of panicking.

Connect a closure to the signal signal_name on this object. Read more

Similar to Self::connect_closure_id but fails instead of panicking.

Connect a closure to the signal signal_id on this object. Read more

Limits the lifetime of closure to the lifetime of the object. When the object’s reference count drops to zero, the closure will be invalidated. An invalidated closure will ignore any calls to invoke_with_values, or invoke when using Rust closures. Read more

Connect to the signal signal_id on this object. Read more

Similar to Self::emit but fails instead of panicking.

Emit signal by signal id. Read more

Similar to Self::emit_with_values but fails instead of panicking.

Same as Self::emit but takes Value for the arguments.

Similar to Self::emit_by_name but fails instead of panicking.

Emit signal by its name. Read more

Similar to Self::emit_by_name_with_values but fails instead of panicking.

Emit signal by its name. Read more

Similar to Self::emit_by_name_with_details but fails instead of panicking.

Emit signal by its name with details. Read more

Similar to Self::emit_by_name_with_details_and_values but fails instead of panicking.

Emit signal by its name with details. Read more

Similar to Self::emit_with_details but fails instead of panicking.

Emit signal by signal id with details. Read more

Similar to Self::emit_with_details_and_values but fails instead of panicking.

Emit signal by signal id with details. Read more

Disconnect a previously connected signal handler.

Connect to the notify signal of the object. Read more

Connect to the notify signal of the object. Read more

Connect to the notify signal of the object. Read more

Notify that the given property has changed its value. Read more

Notify that the given property has changed its value. Read more

Downgrade this object to a weak reference.

Add a callback to be notified when the Object is disposed.

Add a callback to be notified when the Object is disposed. Read more

Bind property source_property on this object to the target_property on the target object. Read more

Returns the strong reference count of this object.

source

impl<T> StaticTypeExt for T where
    T: StaticType

Ensures that the type has been registered with the type system.

source

impl<T> ToClosureReturnValue for T where
    T: ToValue

source

impl<T> ToOwned for T where
    T: Clone

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

source

impl<T> ToString for T where
    T: Display + ?Sized

Converts the given value to a String. Read more

source

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 

The type returned in the event of a conversion error.

Performs the conversion.

source

impl<T> TryFromClosureReturnValue for T where
    T: 'static + for<'a> FromValue<'a> + StaticType

source

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

The type returned in the event of a conversion error.

Performs the conversion.

source

impl<Super, Sub> CanDowncast<Sub> for Super where
    Super: IsA<Super>,
    Sub: IsA<Super>, 

source

impl<'a, T, C, E> FromValueOptional<'a> for T where
    T: FromValue<'a, Checker = C>,
    C: ValueTypeChecker<Error = ValueTypeMismatchOrNoneError<E>>,
    E: 'static + Error + Send