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? 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=

Class methods inherited from module Gtk::Editable

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 start_editing, to_unsafe to_unsafe

Class methods inherited from module Gtk::CellEditable

g_type : UInt64 g_type

Instance methods inherited from module Gtk::ConstraintTarget

to_unsafe to_unsafe

Class methods inherited from module Gtk::ConstraintTarget

g_type : UInt64 g_type

Instance methods inherited from module Gtk::Buildable

buildable_id : String? buildable_id, to_unsafe to_unsafe

Class methods inherited from module Gtk::Buildable

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

Class methods inherited from module Gtk::Accessible

g_type : UInt64 g_type

Instance methods inherited from class Gtk::Widget

action_set_enabled(action_name : String, enabled : Bool) : Nil action_set_enabled, activate : Bool activate, activate_action(name : String, args : _?) : 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 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? 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=, 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?) : 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? cursor, cursor=(cursor : Gdk::Cursor?) : Nil cursor=, cursor_from_name=(name : String?) : 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, dispose_template(widget_type : UInt64) : Nil dispose_template, 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? first_child, focus_child : Gtk::Widget? focus_child, focus_child=(child : Gtk::Widget?) : 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? font_map, font_map=(font_map : Pango::FontMap?) : Nil font_map=, font_options : Cairo::FontOptions? font_options, font_options=(options : Cairo::FontOptions?) : Nil font_options=, frame_clock : Gdk::FrameClock? 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, 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 insert_action_group, insert_after(parent : Gtk::Widget, previous_sibling : Gtk::Widget?) : Nil insert_after, insert_before(parent : Gtk::Widget, next_sibling : Gtk::Widget?) : 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? last_child, layout_manager : Gtk::LayoutManager? layout_manager, layout_manager=(layout_manager : Gtk::LayoutManager?) : 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? native, next_sibling : Gtk::Widget? 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? parent, parent=(parent : Gtk::Widget) : Nil parent=, pick(x : Float64, y : Float64, flags : Gtk::PickFlags) : Gtk::Widget? pick, preferred_size : Gtk::Requisition preferred_size, prev_sibling : Gtk::Widget? 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? 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, tooltip_markup : String? tooltip_markup, tooltip_markup=(value : String) : String
tooltip_markup=(markup : String?) : Nil
tooltip_markup=
, tooltip_text : String? tooltip_text, tooltip_text=(value : String) : String
tooltip_text=(text : String?) : 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, can_focus : Bool? = nil, can_target : Bool? = nil, css_classes : Enumerable(String)? = nil, css_name : String? = nil, cursor : Gdk::Cursor? = nil, focus_on_click : Bool? = nil, focusable : Bool? = nil, halign : Gtk::Align? = nil, has_default : Bool? = nil, has_focus : Bool? = nil, has_tooltip : Bool? = nil, height_request : Int32? = nil, hexpand : Bool? = nil, hexpand_set : Bool? = nil, layout_manager : Gtk::LayoutManager? = nil, margin_bottom : Int32? = nil, margin_end : Int32? = nil, margin_start : Int32? = nil, margin_top : Int32? = nil, name : String? = nil, opacity : Float64? = nil, overflow : Gtk::Overflow? = nil, parent : Gtk::Widget? = nil, receives_default : Bool? = nil, root : Gtk::Root? = nil, scale_factor : Int32? = nil, sensitive : Bool? = nil, tooltip_markup : String? = nil, tooltip_text : String? = nil, valign : Gtk::Align? = nil, vexpand : Bool? = nil, vexpand_set : Bool? = nil, visible : Bool? = nil, width_request : Int32? = 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

Class methods inherited from module Gtk::ConstraintTarget

g_type : UInt64 g_type

Instance methods inherited from module Gtk::Buildable

buildable_id : String? buildable_id, to_unsafe to_unsafe

Class methods inherited from module Gtk::Buildable

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

Class methods inherited from module Gtk::Accessible

g_type : UInt64 g_type

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

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)? data, finalize finalize, freeze_notify : Nil freeze_notify, getv(names : Enumerable(String), values : Enumerable(_)) : Nil getv, 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)? qdata, ref_count : UInt32 ref_count, run_dispose : Nil run_dispose, set_data(key : String, data : Pointer(Void)?) : Nil set_data, set_property(property_name : String, value : _) : Nil set_property, steal_data(key : String) : Pointer(Void)? steal_data, steal_qdata(quark : UInt32) : Pointer(Void)? 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, 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

compat_control(what : UInt64, data : Pointer(Void)?) : 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

Constructor Detail

def self.new : self #

Creates a new entry.


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

def self.new_with_buffer(buffer : Gtk::EntryBuffer) : self #

Creates a new entry with the specified text buffer.


Class Method Detail

def self.g_type : UInt64 #

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


Instance Method Detail

def activate_signal #

def activates_default : Bool #

Retrieves the value set by gtk_entry_set_activates_default().


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.


def activates_default? : Bool #

def alignment : Float32 #

Gets the value set by gtk_entry_set_alignment().

See also: Gtk::Editable#xalign


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


def attributes : Pango::AttrList? #

Gets the attribute list of the Gtk::Entry.

See Gtk::Entry#attributes=.


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.


def attributes=(value : Pango::AttrList?) : Pango::AttrList? #

def buffer : Gtk::EntryBuffer #

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


def buffer=(buffer : Gtk::EntryBuffer) : Nil #

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


def completion : Gtk::EntryCompletion? #

Returns the auxiliary completion object currently in use by @entry.


def completion=(completion : Gtk::EntryCompletion?) : 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.


def current_icon_drag_source : Int32 #

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


def enable_emoji_completion=(value : Bool) : Bool #

def enable_emoji_completion? : Bool #

def extra_menu : Gio::MenuModel? #

Gets the menu model set with gtk_entry_set_extra_menu().


def extra_menu=(model : Gio::MenuModel?) : Nil #

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


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.


def has_frame : Bool #

Gets the value set by gtk_entry_set_has_frame().


def has_frame=(setting : Bool) : Nil #

Sets whether the entry has a beveled frame around it.


def has_frame? : Bool #

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

Returns whether the icon is activatable.


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.


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.


def icon_gicon(icon_pos : Gtk::EntryIconPosition) : Gio::Icon? #

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).


def icon_name(icon_pos : Gtk::EntryIconPosition) : String? #

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).


def icon_paintable(icon_pos : Gtk::EntryIconPosition) : Gdk::Paintable? #

Retrieves the Gdk::Paintable used for the icon.

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


def icon_press_signal #

def icon_release_signal #

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

Returns whether the icon appears sensitive or insensitive.


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.


def icon_tooltip_markup(icon_pos : Gtk::EntryIconPosition) : String? #

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


def icon_tooltip_text(icon_pos : Gtk::EntryIconPosition) : String? #

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


def im_module : String #

def im_module=(value : String) : String #

def input_hints : Gtk::InputHints #

Gets the input hints of this Gtk::Entry.


def input_hints=(hints : Gtk::InputHints) : Nil #

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


def input_purpose : Gtk::InputPurpose #

Gets the input purpose of the Gtk::Entry.


def input_purpose=(purpose : Gtk::InputPurpose) : Nil #

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


def invisible_char : UInt32 #

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


def invisible_char=(ch : UInt32) : 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.


def invisible_char_set=(value : Bool) : Bool #

def invisible_char_set? : Bool #

def max_length : Int32 #

Retrieves the maximum allowed length of the text in @entry.

See Gtk::Entry#max_length=.


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.


def overwrite_mode : Bool #

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


def overwrite_mode=(overwrite : Bool) : Nil #

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


def overwrite_mode? : Bool #

def placeholder_text : String? #

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


def placeholder_text=(value : String) : String #

def placeholder_text=(text : String?) : 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.


def primary_icon_activatable=(value : Bool) : Bool #

def primary_icon_activatable? : Bool #

def primary_icon_gicon : Gio::Icon? #

def primary_icon_gicon=(value : Gio::Icon?) : Gio::Icon? #

def primary_icon_name : String #

def primary_icon_name=(value : String) : String #

def primary_icon_paintable : Gdk::Paintable? #

def primary_icon_paintable=(value : Gdk::Paintable?) : Gdk::Paintable? #

def primary_icon_sensitive=(value : Bool) : Bool #

def primary_icon_sensitive? : Bool #

def primary_icon_storage_type : Gtk::ImageType #

def primary_icon_tooltip_markup : String #

def primary_icon_tooltip_markup=(value : String) : String #

def primary_icon_tooltip_text : String #

def primary_icon_tooltip_text=(value : String) : String #

def progress_fraction : Float64 #

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

See Gtk::Entry#progress_fraction=.


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.


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=).


def progress_pulse_step : Float64 #

Retrieves the pulse step set with gtk_entry_set_progress_pulse_step().


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.


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.


def scroll_offset : Int32 #

def secondary_icon_activatable=(value : Bool) : Bool #

def secondary_icon_activatable? : Bool #

def secondary_icon_gicon : Gio::Icon? #

def secondary_icon_gicon=(value : Gio::Icon?) : Gio::Icon? #

def secondary_icon_name : String #

def secondary_icon_name=(value : String) : String #

def secondary_icon_paintable : Gdk::Paintable? #

def secondary_icon_paintable=(value : Gdk::Paintable?) : Gdk::Paintable? #

def secondary_icon_sensitive=(value : Bool) : Bool #

def secondary_icon_sensitive? : Bool #

def secondary_icon_storage_type : Gtk::ImageType #

def secondary_icon_tooltip_markup : String #

def secondary_icon_tooltip_markup=(value : String) : String #

def secondary_icon_tooltip_text : String #

def secondary_icon_tooltip_text=(value : String) : String #

def set_icon_activatable(icon_pos : Gtk::EntryIconPosition, activatable : Bool) : Nil #

Sets whether the icon is activatable.


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.


def set_icon_from_gicon(icon_pos : Gtk::EntryIconPosition, icon : Gio::Icon?) : 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.


def set_icon_from_icon_name(icon_pos : Gtk::EntryIconPosition, icon_name : String?) : 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.


def set_icon_from_paintable(icon_pos : Gtk::EntryIconPosition, paintable : Gdk::Paintable?) : 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.


def set_icon_sensitive(icon_pos : Gtk::EntryIconPosition, sensitive : Bool) : Nil #

Sets the sensitivity for the specified icon.


def set_icon_tooltip_markup(icon_pos : Gtk::EntryIconPosition, tooltip : String?) : 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=.


def set_icon_tooltip_text(icon_pos : Gtk::EntryIconPosition, tooltip : String?) : 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.


def show_emoji_icon=(value : Bool) : Bool #

def show_emoji_icon? : Bool #

def tabs : Pango::TabArray? #

Gets the tabstops of the `Gtk::Entry.

See Gtk::Entry#tabs=.


def tabs=(tabs : Pango::TabArray?) : Nil #

Sets a Pango::TabArray.

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


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.


def truncate_multiline=(value : Bool) : Bool #

def truncate_multiline? : Bool #

def unset_invisible_char : Nil #

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


def visibility : Bool #

Retrieves whether the text in @entry is visible.

See Gtk::Entry#visibility=.


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.


def visibility? : Bool #