class Gtk::Entry

Overview

Gtk::Entry is a single line text entry widget.

An example Gtk::Entry

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 Gtk::Entry#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 Gtk::Entry#invisible_char=.

Gtk::Entry has the ability to display progress or activity information behind the text. To make an entry display such information, use Gtk::Entry#progress_fraction= or Gtk::Entry#progress_pulse_step=.

Additionally, Gtk::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 Gtk::Entry#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@Gtk.Entry::icon-press] signal. To allow DND operations from an icon, use Gtk::Entry#icon_drag_source=. To set a tooltip on an icon, use Gtk::Entry#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]]

Gtk::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 Gtk::Text.

Gtk::Entry as Gtk::Buildable

The Gtk::Entry implementation of the Gtk::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 Pango::Attribute values for this label.

An example of a UI definition fragment specifying Pango attributes:

WARNING ⚠️ The following code is in xml ⚠️

<object class="Gtk::Entry">
  <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

Gtk::Entry uses the %GTK_ACCESSIBLE_ROLE_TEXT_BOX role.

Included Modules

Defined in:

lib/gi-crystal/src/auto/gtk-4.0/entry.cr

Constructors

Class Method Summary

Instance Method Summary

Instance methods inherited from module Gtk::Editable

alignment : Float32 alignment, alignment=(xalign : Float32) : Nil alignment=, changed_signal changed_signal, chars(start_pos : Int32, end_pos : Int32) : String chars, cursor_position : Int32 cursor_position, delegate : Gtk::Editable | Nil delegate, delete_selection : Nil delete_selection, delete_text(start_pos : Int32, end_pos : Int32) : Nil delete_text, delete_text_signal delete_text_signal, editable : Bool editable, editable=(is_editable : Bool) : Nil editable=, editable? : Bool editable?, enable_undo : Bool enable_undo, enable_undo=(enable_undo : Bool) : Nil enable_undo=, enable_undo? : Bool enable_undo?, finish_delegate : Nil finish_delegate, init_delegate : Nil init_delegate, insert_text(text : String, length : Int32, position : Int32) : Nil insert_text, insert_text_signal insert_text_signal, max_width_chars : Int32 max_width_chars, max_width_chars=(n_chars : Int32) : Nil max_width_chars=, position : Int32 position, position=(position : Int32) : Nil position=, select_region(start_pos : Int32, end_pos : Int32) : Nil select_region, selection_bound : Int32 selection_bound, selection_bounds : Bool selection_bounds, text : String text, text=(text : String) : Nil text=, to_unsafe to_unsafe, width_chars : Int32 width_chars, width_chars=(n_chars : Int32) : Nil width_chars=, xalign : Float32 xalign, xalign=(value : Float32) : Float32 xalign=

Constructor methods inherited from module Gtk::Editable

cast(obj : GObject::Object) : self cast

Class methods inherited from module Gtk::Editable

cast?(obj : GObject::Object) : self | Nil cast?, delegate_get_property(object : GObject::Object, prop_id : UInt32, value : _, pspec : GObject::ParamSpec) : Bool delegate_get_property, delegate_set_property(object : GObject::Object, prop_id : UInt32, value : _, pspec : GObject::ParamSpec) : Bool delegate_set_property, g_type : UInt64 g_type, install_properties(object_class : GObject::ObjectClass, first_prop : UInt32) : UInt32 install_properties

Instance methods inherited from module Gtk::CellEditable

editing_canceled=(value : Bool) : Bool editing_canceled=, editing_canceled? : Bool editing_canceled?, editing_done : Nil editing_done, editing_done_signal editing_done_signal, remove_widget : Nil remove_widget, remove_widget_signal remove_widget_signal, start_editing(event : Gdk::Event | Nil) : Nil start_editing, to_unsafe to_unsafe

Constructor methods inherited from module Gtk::CellEditable

cast(obj : GObject::Object) : self cast

Class methods inherited from module Gtk::CellEditable

cast?(obj : GObject::Object) : self | Nil cast?, g_type : UInt64 g_type

Instance methods inherited from module Gtk::ConstraintTarget

to_unsafe to_unsafe

Constructor methods inherited from module Gtk::ConstraintTarget

cast(obj : GObject::Object) : self cast

Class methods inherited from module Gtk::ConstraintTarget

cast?(obj : GObject::Object) : self | Nil cast?, g_type : UInt64 g_type

Instance methods inherited from module Gtk::Buildable

buildable_id : String | Nil buildable_id, to_unsafe to_unsafe

Constructor methods inherited from module Gtk::Buildable

cast(obj : GObject::Object) : self cast

Class methods inherited from module Gtk::Buildable

cast?(obj : GObject::Object) : self | Nil cast?, g_type : UInt64 g_type

Instance methods inherited from module Gtk::Accessible

accessible_role : Gtk::AccessibleRole accessible_role, accessible_role=(value : Gtk::AccessibleRole) : Gtk::AccessibleRole accessible_role=, reset_property(property : Gtk::AccessibleProperty) : Nil reset_property, reset_relation(relation : Gtk::AccessibleRelation) : Nil reset_relation, reset_state(state : Gtk::AccessibleState) : Nil reset_state, to_unsafe to_unsafe, update_property(properties : Enumerable(Gtk::AccessibleProperty), values : Enumerable(_)) : Nil update_property, update_relation(relations : Enumerable(Gtk::AccessibleRelation), values : Enumerable(_)) : Nil update_relation, update_state(states : Enumerable(Gtk::AccessibleState), values : Enumerable(_)) : Nil update_state

Constructor methods inherited from module Gtk::Accessible

cast(obj : GObject::Object) : self cast

Class methods inherited from module Gtk::Accessible

cast?(obj : GObject::Object) : self | Nil cast?, g_type : UInt64 g_type

Instance methods inherited from class Gtk::Widget

==(other : self) ==, action_set_enabled(action_name : String, enabled : Bool) : Nil action_set_enabled, activate : Bool activate, activate_action(name : String, args : _ | Nil) : Bool activate_action, activate_default : Nil activate_default, add_controller(controller : Gtk::EventController) : Nil add_controller, add_css_class(css_class : String) : Nil add_css_class, add_mnemonic_label(label : Gtk::Widget) : Nil add_mnemonic_label, add_tick_callback(callback : Gtk::TickCallback) : UInt32 add_tick_callback, allocate(width : Int32, height : Int32, baseline : Int32, transform : Gsk::Transform | Nil) : Nil allocate, allocated_baseline : Int32 allocated_baseline, allocated_height : Int32 allocated_height, allocated_width : Int32 allocated_width, allocation : Gdk::Rectangle allocation, ancestor(widget_type : UInt64) : Gtk::Widget | Nil ancestor, can_focus : Bool can_focus, can_focus=(can_focus : Bool) : Nil can_focus=, can_focus? : Bool can_focus?, can_target : Bool can_target, can_target=(can_target : Bool) : Nil can_target=, can_target? : Bool can_target?, child_focus(direction : Gtk::DirectionType) : Bool child_focus, child_visible : Bool child_visible, child_visible=(child_visible : Bool) : Nil child_visible=, children : Iterator(Widget) children, clipboard : Gdk::Clipboard clipboard, compute_bounds(target : Gtk::Widget) : Graphene::Rect compute_bounds, compute_expand(orientation : Gtk::Orientation) : Bool compute_expand, compute_point(target : Gtk::Widget, point : Graphene::Point) : Graphene::Point compute_point, compute_transform(target : Gtk::Widget) : Graphene::Matrix compute_transform, contains(x : Float64, y : Float64) : Bool contains, create_pango_context : Pango::Context create_pango_context, create_pango_layout(text : String | Nil) : Pango::Layout create_pango_layout, css_classes : Enumerable(String) css_classes, css_classes=(classes : Enumerable(String)) : Nil css_classes=, css_name : String css_name, css_name=(value : String) : String css_name=, cursor : Gdk::Cursor | Nil cursor, cursor=(cursor : Gdk::Cursor | Nil) : Nil cursor=, cursor_from_name=(name : String | Nil) : Nil cursor_from_name=, destroy_signal destroy_signal, direction : Gtk::TextDirection direction, direction=(dir : Gtk::TextDirection) : Nil direction=, direction_changed_signal direction_changed_signal, display : Gdk::Display display, drag_check_threshold(start_x : Int32, start_y : Int32, current_x : Int32, current_y : Int32) : Bool drag_check_threshold, error_bell : Nil error_bell, first_child : Gtk::Widget | Nil first_child, focus_child : Gtk::Widget | Nil focus_child, focus_child=(child : Gtk::Widget | Nil) : Nil focus_child=, focus_on_click : Bool focus_on_click, focus_on_click=(focus_on_click : Bool) : Nil focus_on_click=, focus_on_click? : Bool focus_on_click?, focusable : Bool focusable, focusable=(focusable : Bool) : Nil focusable=, focusable? : Bool focusable?, font_map : Pango::FontMap | Nil font_map, font_map=(font_map : Pango::FontMap | Nil) : Nil font_map=, font_options : Cairo::FontOptions | Nil font_options, font_options=(options : Cairo::FontOptions | Nil) : Nil font_options=, frame_clock : Gdk::FrameClock | Nil frame_clock, grab_focus : Bool grab_focus, halign : Gtk::Align halign, halign=(align : Gtk::Align) : Nil halign=, has_css_class(css_class : String) : Bool has_css_class, has_default : Bool has_default, has_default? : Bool has_default?, has_focus : Bool has_focus, has_focus? : Bool has_focus?, has_tooltip : Bool has_tooltip, has_tooltip=(has_tooltip : Bool) : Nil has_tooltip=, has_tooltip? : Bool has_tooltip?, has_visible_focus : Bool has_visible_focus, hash(hasher) hash, height : Int32 height, height_request : Int32 height_request, height_request=(value : Int32) : Int32 height_request=, hexpand : Bool hexpand, hexpand=(expand : Bool) : Nil hexpand=, hexpand? : Bool hexpand?, hexpand_set : Bool hexpand_set, hexpand_set=(set : Bool) : Nil hexpand_set=, hexpand_set? : Bool hexpand_set?, hide : Nil hide, hide_signal hide_signal, in_destruction : Bool in_destruction, init_template : Nil init_template, insert_action_group(name : String, group : Gio::ActionGroup | Nil) : Nil insert_action_group, insert_after(parent : Gtk::Widget, previous_sibling : Gtk::Widget | Nil) : Nil insert_after, insert_before(parent : Gtk::Widget, next_sibling : Gtk::Widget | Nil) : Nil insert_before, is_ancestor(ancestor : Gtk::Widget) : Bool is_ancestor, is_drawable : Bool is_drawable, is_focus : Bool is_focus, is_sensitive : Bool is_sensitive, is_visible : Bool is_visible, keynav_failed(direction : Gtk::DirectionType) : Bool keynav_failed, keynav_failed_signal keynav_failed_signal, last_child : Gtk::Widget | Nil last_child, layout_manager : Gtk::LayoutManager | Nil layout_manager, layout_manager=(layout_manager : Gtk::LayoutManager | Nil) : Nil layout_manager=, list_mnemonic_labels : GLib::List list_mnemonic_labels, map : Nil map, map_signal map_signal, mapped : Bool mapped, margin_bottom : Int32 margin_bottom, margin_bottom=(margin : Int32) : Nil margin_bottom=, margin_end : Int32 margin_end, margin_end=(margin : Int32) : Nil margin_end=, margin_start : Int32 margin_start, margin_start=(margin : Int32) : Nil margin_start=, margin_top : Int32 margin_top, margin_top=(margin : Int32) : Nil margin_top=, measure(orientation : Gtk::Orientation, for_size : Int32) : Nil measure, mnemonic_activate(group_cycling : Bool) : Bool mnemonic_activate, mnemonic_activate_signal mnemonic_activate_signal, move_focus_signal move_focus_signal, name : String name, name=(name : String) : Nil name=, native : Gtk::Native | Nil native, next_sibling : Gtk::Widget | Nil next_sibling, observe_children : Gio::ListModel observe_children, observe_controllers : Gio::ListModel observe_controllers, opacity : Float64 opacity, opacity=(opacity : Float64) : Nil opacity=, overflow : Gtk::Overflow overflow, overflow=(overflow : Gtk::Overflow) : Nil overflow=, pango_context : Pango::Context pango_context, parent : Gtk::Widget | Nil parent, parent=(parent : Gtk::Widget) : Nil parent=, pick(x : Float64, y : Float64, flags : Gtk::PickFlags) : Gtk::Widget | Nil pick, preferred_size : Gtk::Requisition preferred_size, prev_sibling : Gtk::Widget | Nil prev_sibling, primary_clipboard : Gdk::Clipboard primary_clipboard, query_tooltip_signal query_tooltip_signal, queue_allocate : Nil queue_allocate, queue_draw : Nil queue_draw, queue_resize : Nil queue_resize, realize : Nil realize, realize_signal realize_signal, realized : Bool realized, receives_default : Bool receives_default, receives_default=(receives_default : Bool) : Nil receives_default=, receives_default? : Bool receives_default?, remove_controller(controller : Gtk::EventController) : Nil remove_controller, remove_css_class(css_class : String) : Nil remove_css_class, remove_mnemonic_label(label : Gtk::Widget) : Nil remove_mnemonic_label, remove_tick_callback(id : UInt32) : Nil remove_tick_callback, request_mode : Gtk::SizeRequestMode request_mode, root : Gtk::Root | Nil root, scale_factor : Int32 scale_factor, sensitive : Bool sensitive, sensitive=(sensitive : Bool) : Nil sensitive=, sensitive? : Bool sensitive?, set_size_request(width : Int32, height : Int32) : Nil set_size_request, set_state_flags(flags : Gtk::StateFlags, clear : Bool) : Nil set_state_flags, settings : Gtk::Settings settings, should_layout : Bool should_layout, show : Nil show, show_signal show_signal, size(orientation : Gtk::Orientation) : Int32 size, size_allocate(allocation : Gdk::Rectangle, baseline : Int32) : Nil size_allocate, size_request : Nil size_request, snapshot_child(child : Gtk::Widget, snapshot : Gtk::Snapshot) : Nil snapshot_child, state_flags : Gtk::StateFlags state_flags, state_flags_changed_signal state_flags_changed_signal, style_context : Gtk::StyleContext style_context, template_child(widget_type : UInt64, name : String) : GObject::Object
template_child(name : String) : GObject::Object
template_child
, tooltip_markup : String | Nil tooltip_markup, tooltip_markup=(value : String) : String
tooltip_markup=(markup : String | Nil) : Nil
tooltip_markup=
, tooltip_text : String | Nil tooltip_text, tooltip_text=(value : String) : String
tooltip_text=(text : String | Nil) : Nil
tooltip_text=
, translate_coordinates(dest_widget : Gtk::Widget, src_x : Float64, src_y : Float64) : Bool translate_coordinates, trigger_tooltip_query : Nil trigger_tooltip_query, unmap : Nil unmap, unmap_signal unmap_signal, unparent : Nil unparent, unrealize : Nil unrealize, unrealize_signal unrealize_signal, unset_state_flags(flags : Gtk::StateFlags) : Nil unset_state_flags, valign : Gtk::Align valign, valign=(align : Gtk::Align) : Nil valign=, vexpand : Bool vexpand, vexpand=(expand : Bool) : Nil vexpand=, vexpand? : Bool vexpand?, vexpand_set : Bool vexpand_set, vexpand_set=(set : Bool) : Nil vexpand_set=, vexpand_set? : Bool vexpand_set?, visible : Bool visible, visible=(visible : Bool) : Nil visible=, visible? : Bool visible?, width : Int32 width, width_request : Int32 width_request, width_request=(value : Int32) : Int32 width_request=

Constructor methods inherited from class Gtk::Widget

new
new(*, accessible_role : Gtk::AccessibleRole | Nil = nil, can_focus : Bool | Nil = nil, can_target : Bool | Nil = nil, css_classes : Enumerable(String) | Nil = nil, css_name : String | Nil = nil, cursor : Gdk::Cursor | Nil = nil, focus_on_click : Bool | Nil = nil, focusable : Bool | Nil = nil, halign : Gtk::Align | Nil = nil, has_default : Bool | Nil = nil, has_focus : Bool | Nil = nil, has_tooltip : Bool | Nil = nil, height_request : Int32 | Nil = nil, hexpand : Bool | Nil = nil, hexpand_set : Bool | Nil = nil, layout_manager : Gtk::LayoutManager | Nil = nil, margin_bottom : Int32 | Nil = nil, margin_end : Int32 | Nil = nil, margin_start : Int32 | Nil = nil, margin_top : Int32 | Nil = nil, name : String | Nil = nil, opacity : Float64 | Nil = nil, overflow : Gtk::Overflow | Nil = nil, parent : Gtk::Widget | Nil = nil, receives_default : Bool | Nil = nil, root : Gtk::Root | Nil = nil, scale_factor : Int32 | Nil = nil, sensitive : Bool | Nil = nil, tooltip_markup : String | Nil = nil, tooltip_text : String | Nil = nil, valign : Gtk::Align | Nil = nil, vexpand : Bool | Nil = nil, vexpand_set : Bool | Nil = nil, visible : Bool | Nil = nil, width_request : Int32 | Nil = nil)
new

Class methods inherited from class Gtk::Widget

default_direction : Gtk::TextDirection default_direction, default_direction=(dir : Gtk::TextDirection) : Nil default_direction=, g_type : UInt64 g_type

Instance methods inherited from module Gtk::ConstraintTarget

to_unsafe to_unsafe

Constructor methods inherited from module Gtk::ConstraintTarget

cast(obj : GObject::Object) : self cast

Class methods inherited from module Gtk::ConstraintTarget

cast?(obj : GObject::Object) : self | Nil cast?, g_type : UInt64 g_type

Instance methods inherited from module Gtk::Buildable

buildable_id : String | Nil buildable_id, to_unsafe to_unsafe

Constructor methods inherited from module Gtk::Buildable

cast(obj : GObject::Object) : self cast

Class methods inherited from module Gtk::Buildable

cast?(obj : GObject::Object) : self | Nil cast?, g_type : UInt64 g_type

Instance methods inherited from module Gtk::Accessible

accessible_role : Gtk::AccessibleRole accessible_role, accessible_role=(value : Gtk::AccessibleRole) : Gtk::AccessibleRole accessible_role=, reset_property(property : Gtk::AccessibleProperty) : Nil reset_property, reset_relation(relation : Gtk::AccessibleRelation) : Nil reset_relation, reset_state(state : Gtk::AccessibleState) : Nil reset_state, to_unsafe to_unsafe, update_property(properties : Enumerable(Gtk::AccessibleProperty), values : Enumerable(_)) : Nil update_property, update_relation(relations : Enumerable(Gtk::AccessibleRelation), values : Enumerable(_)) : Nil update_relation, update_state(states : Enumerable(Gtk::AccessibleState), values : Enumerable(_)) : Nil update_state

Constructor methods inherited from module Gtk::Accessible

cast(obj : GObject::Object) : self cast

Class methods inherited from module Gtk::Accessible

cast?(obj : GObject::Object) : self | Nil cast?, g_type : UInt64 g_type

Instance methods inherited from class GObject::InitiallyUnowned

==(other : self) ==, hash(hasher) hash

Constructor methods inherited from class GObject::InitiallyUnowned

new new

Class methods inherited from class GObject::InitiallyUnowned

g_type : UInt64 g_type

Instance methods inherited from class GObject::Object

==(other : self) ==, bind_property(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags) : GObject::Binding bind_property, bind_property_full(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags, transform_to : GObject::Closure, transform_from : GObject::Closure) : GObject::Binding bind_property_full, data(key : String) : Pointer(Void) | Nil data, finalize finalize, freeze_notify : Nil freeze_notify, getv(names : Enumerable(String), values : Enumerable(_)) : Nil getv, hash(hasher) hash, notify(property_name : String) : Nil notify, notify_by_pspec(pspec : GObject::ParamSpec) : Nil notify_by_pspec, notify_signal notify_signal, property(property_name : String, value : _) : Nil property, qdata(quark : UInt32) : Pointer(Void) | Nil qdata, ref_count : UInt32 ref_count, run_dispose : Nil run_dispose, set_data(key : String, data : Pointer(Void) | Nil) : Nil set_data, set_property(property_name : String, value : _) : Nil set_property, steal_data(key : String) : Pointer(Void) | Nil steal_data, steal_qdata(quark : UInt32) : Pointer(Void) | Nil steal_qdata, thaw_notify : Nil thaw_notify, to_unsafe : Pointer(Void) to_unsafe, watch_closure(closure : GObject::Closure) : Nil watch_closure

Constructor methods inherited from class GObject::Object

cast(obj : GObject::Object) : self cast, new(pointer : Pointer(Void), transfer : GICrystal::Transfer)
new
new
, newv(object_type : UInt64, parameters : Enumerable(GObject::Parameter)) : self newv

Class methods inherited from class GObject::Object

cast?(obj : GObject::Object) : self | Nil cast?, compat_control(what : UInt64, data : Pointer(Void) | Nil) : UInt64 compat_control, g_type : UInt64 g_type, interface_find_property(g_iface : GObject::TypeInterface, property_name : String) : GObject::ParamSpec interface_find_property, interface_list_properties(g_iface : GObject::TypeInterface) : Enumerable(GObject::ParamSpec) interface_list_properties

Macros inherited from class GObject::Object

previous_vfunc(*args) previous_vfunc, previous_vfunc!(*args) previous_vfunc!, signal(signature) signal

Constructor Detail

def self.new : self #

Creates a new entry.


[View source]
def self.new(*, accessible_role : Gtk::AccessibleRole | Nil = nil, activates_default : Bool | Nil = nil, attributes : Pango::AttrList | Nil = nil, buffer : Gtk::EntryBuffer | Nil = nil, can_focus : Bool | Nil = nil, can_target : Bool | Nil = nil, completion : Gtk::EntryCompletion | Nil = nil, css_classes : Enumerable(String) | Nil = nil, css_name : String | Nil = nil, cursor : Gdk::Cursor | Nil = nil, cursor_position : Int32 | Nil = nil, editable : Bool | Nil = nil, editing_canceled : Bool | Nil = nil, enable_emoji_completion : Bool | Nil = nil, enable_undo : Bool | Nil = nil, extra_menu : Gio::MenuModel | Nil = nil, focus_on_click : Bool | Nil = nil, focusable : Bool | Nil = nil, halign : Gtk::Align | Nil = nil, has_default : Bool | Nil = nil, has_focus : Bool | Nil = nil, has_frame : Bool | Nil = nil, has_tooltip : Bool | Nil = nil, height_request : Int32 | Nil = nil, hexpand : Bool | Nil = nil, hexpand_set : Bool | Nil = nil, im_module : String | Nil = nil, input_hints : Gtk::InputHints | Nil = nil, input_purpose : Gtk::InputPurpose | Nil = nil, invisible_char : UInt32 | Nil = nil, invisible_char_set : Bool | Nil = nil, layout_manager : Gtk::LayoutManager | Nil = nil, margin_bottom : Int32 | Nil = nil, margin_end : Int32 | Nil = nil, margin_start : Int32 | Nil = nil, margin_top : Int32 | Nil = nil, max_length : Int32 | Nil = nil, max_width_chars : Int32 | Nil = nil, name : String | Nil = nil, opacity : Float64 | Nil = nil, overflow : Gtk::Overflow | Nil = nil, overwrite_mode : Bool | Nil = nil, parent : Gtk::Widget | Nil = nil, placeholder_text : String | Nil = nil, primary_icon_activatable : Bool | Nil = nil, primary_icon_gicon : Gio::Icon | Nil = nil, primary_icon_name : String | Nil = nil, primary_icon_paintable : Gdk::Paintable | Nil = nil, primary_icon_sensitive : Bool | Nil = nil, primary_icon_storage_type : Gtk::ImageType | Nil = nil, primary_icon_tooltip_markup : String | Nil = nil, primary_icon_tooltip_text : String | Nil = nil, progress_fraction : Float64 | Nil = nil, progress_pulse_step : Float64 | Nil = nil, receives_default : Bool | Nil = nil, root : Gtk::Root | Nil = nil, scale_factor : Int32 | Nil = nil, scroll_offset : Int32 | Nil = nil, secondary_icon_activatable : Bool | Nil = nil, secondary_icon_gicon : Gio::Icon | Nil = nil, secondary_icon_name : String | Nil = nil, secondary_icon_paintable : Gdk::Paintable | Nil = nil, secondary_icon_sensitive : Bool | Nil = nil, secondary_icon_storage_type : Gtk::ImageType | Nil = nil, secondary_icon_tooltip_markup : String | Nil = nil, secondary_icon_tooltip_text : String | Nil = nil, selection_bound : Int32 | Nil = nil, sensitive : Bool | Nil = nil, show_emoji_icon : Bool | Nil = nil, tabs : Pango::TabArray | Nil = nil, text : String | Nil = nil, text_length : UInt32 | Nil = nil, tooltip_markup : String | Nil = nil, tooltip_text : String | Nil = nil, truncate_multiline : Bool | Nil = nil, valign : Gtk::Align | Nil = nil, vexpand : Bool | Nil = nil, vexpand_set : Bool | Nil = nil, visibility : Bool | Nil = nil, visible : Bool | Nil = nil, width_chars : Int32 | Nil = nil, width_request : Int32 | Nil = nil, xalign : Float32 | Nil = nil) #

[View source]
def self.new_with_buffer(buffer : Gtk::EntryBuffer) : self #

Creates a new entry with the specified text buffer.


[View source]

Class Method Detail

def self.g_type : UInt64 #

Returns the type id (GType) registered in GLib type system.


[View source]

Instance Method Detail

def ==(other : self) #
Description copied from class Reference

Returns true if this reference is the same as other. Invokes same?.


def activate_signal #

[View source]
def activates_default : Bool #

Retrieves the value set by gtk_entry_set_activates_default().


[View source]
def activates_default=(setting : Bool) : Nil #

Sets whether pressing Enter in the entry will activate the default widget for the window containing the entry.

This usually means that the dialog containing the entry will be closed, since the default widget is usually one of the dialog buttons.


[View source]
def activates_default? : Bool #

[View source]
def alignment : Float32 #

Gets the value set by gtk_entry_set_alignment().

See also: Gtk::Editable#xalign


[View source]
def alignment=(xalign : Float32) : Nil #

Sets the alignment for the contents of the entry.

This controls the horizontal positioning of the contents when the displayed text is shorter than the width of the entry.

See also: Gtk::Editable#xalign


[View source]
def attributes : Pango::AttrList | Nil #

Gets the attribute list of the Gtk::Entry.

See Gtk::Entry#attributes=.


[View source]
def attributes=(attrs : Pango::AttrList) : Nil #

Sets a Pango::AttrList.

The attributes in the list are applied to the entry text.

Since the attributes will be applies to text that changes as the user types, it makes most sense to use attributes with unlimited extent.


[View source]
def attributes=(value : Pango::AttrList | Nil) : Pango::AttrList | Nil #

[View source]
def buffer : Gtk::EntryBuffer #

Get the Gtk::EntryBuffer object which holds the text for this widget.


[View source]
def buffer=(buffer : Gtk::EntryBuffer) : Nil #

Set the Gtk::EntryBuffer object which holds the text for this widget.


[View source]
def completion : Gtk::EntryCompletion | Nil #

Returns the auxiliary completion object currently in use by entry.


[View source]
def completion=(completion : Gtk::EntryCompletion | Nil) : Nil #

Sets completion to be the auxiliary completion object to use with entry.

All further configuration of the completion mechanism is done on completion using the Gtk::EntryCompletion API. Completion is disabled if completion is set to nil.


[View source]
def current_icon_drag_source : Int32 #

Returns the index of the icon which is the source of the current DND operation, or -1.


[View source]
def enable_emoji_completion=(value : Bool) : Bool #

[View source]
def enable_emoji_completion? : Bool #

[View source]
def extra_menu : Gio::MenuModel | Nil #

Gets the menu model set with gtk_entry_set_extra_menu().


[View source]
def extra_menu=(model : Gio::MenuModel | Nil) : Nil #

Sets a menu model to add when constructing the context menu for entry.


[View source]
def grab_focus_without_selecting : Bool #

Causes entry to have keyboard focus.

It behaves like Gtk::Widget#grab_focus, except that it doesn't select the contents of the entry. You only want to call this on some special entries which the user usually doesn't want to replace all text in, such as search-as-you-type entries.


[View source]
def has_frame : Bool #

Gets the value set by gtk_entry_set_has_frame().


[View source]
def has_frame=(setting : Bool) : Nil #

Sets whether the entry has a beveled frame around it.


[View source]
def has_frame? : Bool #

[View source]
def hash(hasher) #
Description copied from class Reference

See Object#hash(hasher)


def icon_activatable(icon_pos : Gtk::EntryIconPosition) : Bool #

Returns whether the icon is activatable.


[View source]
def icon_area(icon_pos : Gtk::EntryIconPosition) : Gdk::Rectangle #

Gets the area where entry’s icon at icon_pos is drawn.

This function is useful when drawing something to the entry in a draw callback.

If the entry is not realized or has no icon at the given position, icon_area is filled with zeros. Otherwise, icon_area will be filled with the icon's allocation, relative to entry's allocation.


[View source]
def icon_at_pos(x : Int32, y : Int32) : Int32 #

Finds the icon at the given position and return its index.

The position’s coordinates are relative to the entry’s top left corner. If x, y doesn’t lie inside an icon, -1 is returned. This function is intended for use in a [signal@Gtk.Widget::query-tooltip] signal handler.


[View source]
def icon_gicon(icon_pos : Gtk::EntryIconPosition) : Gio::Icon | Nil #

Retrieves the GIcon used for the icon.

nil will be returned if there is no icon or if the icon was set by some other method (e.g., by Gdk::Paintable or icon name).


[View source]
def icon_name(icon_pos : Gtk::EntryIconPosition) : String | Nil #

Retrieves the icon name used for the icon.

nil is returned if there is no icon or if the icon was set by some other method (e.g., by Gdk::Paintable or gicon).


[View source]
def icon_paintable(icon_pos : Gtk::EntryIconPosition) : Gdk::Paintable | Nil #

Retrieves the Gdk::Paintable used for the icon.

If no Gdk::Paintable was used for the icon, nil is returned.


[View source]
def icon_press_signal #

[View source]
def icon_release_signal #

[View source]
def icon_sensitive(icon_pos : Gtk::EntryIconPosition) : Bool #

Returns whether the icon appears sensitive or insensitive.


[View source]
def icon_storage_type(icon_pos : Gtk::EntryIconPosition) : Gtk::ImageType #

Gets the type of representation being used by the icon to store image data.

If the icon has no image data, the return value will be %GTK_IMAGE_EMPTY.


[View source]
def icon_tooltip_markup(icon_pos : Gtk::EntryIconPosition) : String | Nil #

Gets the contents of the tooltip on the icon at the specified position in entry.


[View source]
def icon_tooltip_text(icon_pos : Gtk::EntryIconPosition) : String | Nil #

Gets the contents of the tooltip on the icon at the specified position in entry.


[View source]
def im_module : String #

[View source]
def im_module=(value : String) : String #

[View source]
def input_hints : Gtk::InputHints #

Gets the input hints of this Gtk::Entry.


[View source]
def input_hints=(hints : Gtk::InputHints) : Nil #

Set additional hints which allow input methods to fine-tune their behavior.


[View source]
def input_purpose : Gtk::InputPurpose #

Gets the input purpose of the Gtk::Entry.


[View source]
def input_purpose=(purpose : Gtk::InputPurpose) : Nil #

Sets the input purpose which can be used by input methods to adjust their behavior.


[View source]
def invisible_char : Char #

Retrieves the character displayed in place of the actual text in “password mode”.


[View source]
def invisible_char=(value : UInt32) : UInt32 #

[View source]
def invisible_char=(ch : Char) : Nil #

Sets the character to use in place of the actual text in “password mode”.

See Gtk::Entry#visibility= for how to enable “password mode”.

By default, GTK picks the best invisible char available in the current font. If you set the invisible char to 0, then the user will get no feedback at all; there will be no text on the screen as they type.


[View source]
def invisible_char_set=(value : Bool) : Bool #

[View source]
def invisible_char_set? : Bool #

[View source]
def max_length : Int32 #

Retrieves the maximum allowed length of the text in entry.

See Gtk::Entry#max_length=.


[View source]
def max_length=(max : Int32) : Nil #

Sets the maximum allowed length of the contents of the widget.

If the current contents are longer than the given length, then they will be truncated to fit. The length is is in characters.

This is equivalent to getting entry's Gtk::EntryBuffer and calling Gtk::EntryBuffer#max_length= on it.


[View source]
def overwrite_mode : Bool #

Gets whether the Gtk::Entry is in overwrite mode.


[View source]
def overwrite_mode=(overwrite : Bool) : Nil #

Sets whether the text is overwritten when typing in the Gtk::Entry.


[View source]
def overwrite_mode? : Bool #

[View source]
def placeholder_text : String | Nil #

Retrieves the text that will be displayed when entry is empty and unfocused


[View source]
def placeholder_text=(value : String) : String #

[View source]
def placeholder_text=(text : String | Nil) : Nil #

Sets text to be displayed in entry when it is empty.

This can be used to give a visual hint of the expected contents of the Gtk::Entry.


[View source]
def primary_icon_activatable=(value : Bool) : Bool #

[View source]
def primary_icon_activatable? : Bool #

[View source]
def primary_icon_gicon : Gio::Icon | Nil #

[View source]
def primary_icon_gicon=(value : Gio::Icon | Nil) : Gio::Icon | Nil #

[View source]
def primary_icon_name : String #

[View source]
def primary_icon_name=(value : String) : String #

[View source]
def primary_icon_paintable : Gdk::Paintable | Nil #

[View source]
def primary_icon_paintable=(value : Gdk::Paintable | Nil) : Gdk::Paintable | Nil #

[View source]
def primary_icon_sensitive=(value : Bool) : Bool #

[View source]
def primary_icon_sensitive? : Bool #

[View source]
def primary_icon_storage_type : Gtk::ImageType #

[View source]
def primary_icon_tooltip_markup : String #

[View source]
def primary_icon_tooltip_markup=(value : String) : String #

[View source]
def primary_icon_tooltip_text : String #

[View source]
def primary_icon_tooltip_text=(value : String) : String #

[View source]
def progress_fraction : Float64 #

Returns the current fraction of the task that’s been completed.

See Gtk::Entry#progress_fraction=.


[View source]
def progress_fraction=(fraction : Float64) : Nil #

Causes the entry’s progress indicator to “fill in” the given fraction of the bar.

The fraction should be between 0.0 and 1.0, inclusive.


[View source]
def progress_pulse : Nil #

Indicates that some progress is made, but you don’t know how much.

Causes the entry’s progress indicator to enter “activity mode”, where a block bounces back and forth. Each call to gtk_entry_progress_pulse() causes the block to move by a little bit (the amount of movement per pulse is determined by Gtk::Entry#progress_pulse_step=).


[View source]
def progress_pulse_step : Float64 #

Retrieves the pulse step set with gtk_entry_set_progress_pulse_step().


[View source]
def progress_pulse_step=(fraction : Float64) : Nil #

Sets the fraction of total entry width to move the progress bouncing block for each pulse.

Use Gtk::Entry#progress_pulse to pulse the progress.


[View source]
def reset_im_context : Nil #

Reset the input method context of the entry if needed.

This can be necessary in the case where modifying the buffer would confuse on-going input method behavior.


[View source]
def scroll_offset : Int32 #

[View source]
def secondary_icon_activatable=(value : Bool) : Bool #

[View source]
def secondary_icon_activatable? : Bool #

[View source]
def secondary_icon_gicon : Gio::Icon | Nil #

[View source]
def secondary_icon_gicon=(value : Gio::Icon | Nil) : Gio::Icon | Nil #

[View source]
def secondary_icon_name : String #

[View source]
def secondary_icon_name=(value : String) : String #

[View source]
def secondary_icon_paintable : Gdk::Paintable | Nil #

[View source]
def secondary_icon_paintable=(value : Gdk::Paintable | Nil) : Gdk::Paintable | Nil #

[View source]
def secondary_icon_sensitive=(value : Bool) : Bool #

[View source]
def secondary_icon_sensitive? : Bool #

[View source]
def secondary_icon_storage_type : Gtk::ImageType #

[View source]
def secondary_icon_tooltip_markup : String #

[View source]
def secondary_icon_tooltip_markup=(value : String) : String #

[View source]
def secondary_icon_tooltip_text : String #

[View source]
def secondary_icon_tooltip_text=(value : String) : String #

[View source]
def set_icon_activatable(icon_pos : Gtk::EntryIconPosition, activatable : Bool) : Nil #

Sets whether the icon is activatable.


[View source]
def set_icon_drag_source(icon_pos : Gtk::EntryIconPosition, provider : Gdk::ContentProvider, actions : Gdk::DragAction) : Nil #

Sets up the icon at the given position as drag source.

This makes it so that GTK will start a drag operation when the user clicks and drags the icon.


[View source]
def set_icon_from_gicon(icon_pos : Gtk::EntryIconPosition, icon : Gio::Icon | Nil) : Nil #

Sets the icon shown in the entry at the specified position from the current icon theme.

If the icon isn’t known, a “broken image” icon will be displayed instead.

If icon is nil, no icon will be shown in the specified position.


[View source]
def set_icon_from_icon_name(icon_pos : Gtk::EntryIconPosition, icon_name : String | Nil) : Nil #

Sets the icon shown in the entry at the specified position from the current icon theme.

If the icon name isn’t known, a “broken image” icon will be displayed instead.

If icon_name is nil, no icon will be shown in the specified position.


[View source]
def set_icon_from_paintable(icon_pos : Gtk::EntryIconPosition, paintable : Gdk::Paintable | Nil) : Nil #

Sets the icon shown in the specified position using a Gdk::Paintable.

If paintable is nil, no icon will be shown in the specified position.


[View source]
def set_icon_sensitive(icon_pos : Gtk::EntryIconPosition, sensitive : Bool) : Nil #

Sets the sensitivity for the specified icon.


[View source]
def set_icon_tooltip_markup(icon_pos : Gtk::EntryIconPosition, tooltip : String | Nil) : Nil #

Sets tooltip as the contents of the tooltip for the icon at the specified position. tooltip is assumed to be marked up with Pango Markup.

Use nil for tooltip to remove an existing tooltip.

See also Gtk::Widget#tooltip_markup= and Gtk::Entry#icon_tooltip_text=.


[View source]
def set_icon_tooltip_text(icon_pos : Gtk::EntryIconPosition, tooltip : String | Nil) : Nil #

Sets tooltip as the contents of the tooltip for the icon at the specified position.

Use nil for tooltip to remove an existing tooltip.

See also Gtk::Widget#tooltip_text= and Gtk::Entry#icon_tooltip_markup=.

If you unset the widget tooltip via Gtk::Widget#tooltip_text= or Gtk::Widget#tooltip_markup=, this sets [property@Gtk.Widget:has-tooltip] to false, which suppresses icon tooltips too. You can resolve this by then calling Gtk::Widget#has_tooltip= to set [property@Gtk.Widget:has-tooltip] back to true, or setting at least one non-empty tooltip on any icon achieves the same result.


[View source]
def show_emoji_icon=(value : Bool) : Bool #

[View source]
def show_emoji_icon? : Bool #

[View source]
def tabs : Pango::TabArray | Nil #

Gets the tabstops of the `Gtk::Entry.

See Gtk::Entry#tabs=.


[View source]
def tabs=(tabs : Pango::TabArray | Nil) : Nil #

Sets a Pango::TabArray.

The tabstops in the array are applied to the entry text.


[View source]
def text_length : UInt16 #

Retrieves the current length of the text in entry.

This is equivalent to getting entry's Gtk::EntryBuffer and calling Gtk::EntryBuffer#length on it.


[View source]
def truncate_multiline=(value : Bool) : Bool #

[View source]
def truncate_multiline? : Bool #

[View source]
def unset_invisible_char : Nil #

Unsets the invisible char, so that the default invisible char is used again. See Gtk::Entry#invisible_char=.


[View source]
def visibility : Bool #

Retrieves whether the text in entry is visible.

See Gtk::Entry#visibility=.


[View source]
def visibility=(visible : Bool) : Nil #

Sets whether the contents of the entry are visible or not.

When visibility is set to false, characters are displayed as the invisible char, and will also appear that way when the text in the entry widget is copied elsewhere.

By default, GTK picks the best invisible character available in the current font, but it can be changed with Gtk::Entry#invisible_char=.

Note that you probably want to set [property@Gtk.Entry:input-purpose] to %GTK_INPUT_PURPOSE_PASSWORD or %GTK_INPUT_PURPOSE_PIN to inform input methods about the purpose of this entry, in addition to setting visibility to false.


[View source]
def visibility? : Bool #

[View source]