Entry
Object Hierarchy:
Description:
public class Entry : Widget, Implementor, Buildable, CellEditable, Editable
The Entry widget is a single line text entry widget.
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 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 set_invisible_char. Since 2.16, GTK+ displays a warning when Caps Lock or input methods might interfere with entering text in a password entry. The warning can be turned off with the caps_lock_warning property.
Since 2.16, GtkEntry has the ability to display progress or activity information behind the text. To make an entry display such information, use set_progress_fraction or set_progress_pulse_step.
Additionally, GtkEntry 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 set_icon_from_gicon or one of the various other functions that set an icon from a stock id, an icon name or a pixbuf. To trigger an action when the user clicks an icon, connect to the icon_press signal. To allow DND operations from an icon, use set_icon_drag_source. To set a tooltip on an icon, use 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[.read-only][.flat][.warning][.error]
├── image.left
├── image.right
├── undershoot.left
├── undershoot.right
├── [selection]
├── [progress[.pulse]]
╰── [window.popup]
ntry. 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 has a selection, it adds a subnode with the name selection.
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.
The CSS node for a context menu is added as a subnode below entry as well.
The undershoot nodes are used to draw the underflow indication when content is scrolled out of view. These nodes get the .left and .right style classes added depending on where the indication is drawn.
When touch is used and touch selection handles are shown, they are using CSS nodes with name cursor-handle. They get the .top or .bottom style class depending on where they are shown in relation to the selection. If there is just a single handle for the text cursor, it gets the style class .insertion-cursor.

Content:
Properties:
- public bool activates_default { get; set; }
- public AttrList attributes { get; set; }
A list of Pango attributes to apply to the text of the entry.
- public EntryBuffer buffer { get; set construct; }
- public bool caps_lock_warning { get; set; }
Whether password entries will show a warning when Caps Lock is on.
- public EntryCompletion completion { get; set; }
The auxiliary completion object to use with the entry.
- public int cursor_position { get; }
- public bool editable { get; set; }
- public bool enable_emoji_completion { get; set; }
- public bool has_frame { get; set; }
- public string im_module { owned get; set; }
Which IM (input method) module should be used for this entry.
- public Border inner_border { get; set; }
Sets the text area's border between the text and the frame.
- public InputHints input_hints { get; set; }
Additional hints (beyond input_purpose) that allow input methods to fine-tune their behaviour.
- public InputPurpose input_purpose { get; set; }
The purpose of this text field.
- public uint invisible_char { get; set; }
The invisible character is used when masking entry contents (in \"password mode\")").
- public bool invisible_char_set { get; set; }
Whether the invisible char has been set for the Entry .
- public int max_length { get; set; }
- public int max_width_chars { get; set; }
The desired maximum width of the entry, in characters.
- public bool overwrite_mode { get; set; }
If text is overwritten when typing in the Entry.
- public string placeholder_text { get; set; }
The text that will be displayed in the Entry when it is empty and unfocused.
- public bool populate_all { get; set; }
If populate_all is true, the populate_popup signal is also emitted for touch popups.
- public bool primary_icon_activatable { get; set; }
Whether the primary icon is activatable.
- public Icon primary_icon_gicon { owned get; set; }
The Icon to use for the primary icon for the entry.
- public string primary_icon_name { owned get; set; }
The icon name to use for the primary icon for the entry.
- public Pixbuf primary_icon_pixbuf { owned get; set; }
A pixbuf to use as the primary icon for the entry.
- public bool primary_icon_sensitive { get; set; }
Whether the primary icon is sensitive.
- public string primary_icon_stock { owned get; set; }
The stock id to use for the primary icon for the entry.
- public ImageType primary_icon_storage_type { get; }
The representation which is used for the primary icon of the entry.
- public string primary_icon_tooltip_markup { owned get; set; }
The contents of the tooltip on the primary icon, which is marked up with the Pango text markup language.
- public string primary_icon_tooltip_text { owned get; set; }
The contents of the tooltip on the primary icon.
- public double progress_fraction { get; set; }
The current fraction of the task that's been completed.
- public double progress_pulse_step { get; set; }
The fraction of total entry width to move the progress bouncing block for each call to progress_pulse.
- public int scroll_offset { get; }
- public bool secondary_icon_activatable { get; set; }
Whether the secondary icon is activatable.
- public Icon secondary_icon_gicon { owned get; set; }
The Icon to use for the secondary icon for the entry.
- public string secondary_icon_name { owned get; set; }
The icon name to use for the secondary icon for the entry.
- public Pixbuf secondary_icon_pixbuf { owned get; set; }
An pixbuf to use as the secondary icon for the entry.
- public bool secondary_icon_sensitive { get; set; }
Whether the secondary icon is sensitive.
- public string secondary_icon_stock { owned get; set; }
The stock id to use for the secondary icon for the entry.
- public ImageType secondary_icon_storage_type { get; }
The representation which is used for the secondary icon of the entry.
- public string secondary_icon_tooltip_markup { owned get; set; }
The contents of the tooltip on the secondary icon, which is marked up with the Pango text markup language.
- public string secondary_icon_tooltip_text { owned get; set; }
The contents of the tooltip on the secondary icon.
- public int selection_bound { get; }
- public ShadowType shadow_type { get; set; }
Which kind of shadow to draw around the entry when has_frame is set to true.
- public bool show_emoji_icon { get; set; }
- public TabArray tabs { get; set; }
- public string text { get; set; }
- public uint text_length { get; }
The length of the text in the Entry.
- public bool truncate_multiline { get; set; }
When true, pasted multi-line text is truncated to the first line.
- public bool visibility { get; set; }
- public int width_chars { get; set; }
- public float xalign { get; set; }
The horizontal alignment, from 0 (left) to 1 (right).
Creation methods:
- public Entry ()
Creates a new entry.
- public Entry.with_buffer (EntryBuffer buffer)
Creates a new entry with the specified text buffer.
Methods:
- public bool get_activates_default ()
Retrieves the value set by set_activates_default.
- public float get_alignment ()
Gets the value set by set_alignment.
- public unowned AttrList? get_attributes ()
Gets the attribute list that was set on the entry using set_attributes, if any.
- public unowned EntryBuffer get_buffer ()
Get the EntryBuffer object which holds the text for this widget.
- public unowned EntryCompletion get_completion ()
Returns the auxiliary completion object currently in use by this.
- public int get_current_icon_drag_source ()
Returns the index of the icon which is the source of the current DND operation, or -1.
- public unowned Adjustment? get_cursor_hadjustment ()
Retrieves the horizontal cursor adjustment for the entry.
- public virtual void get_frame_size (out int x, out int y, out int width, out int height)
- public bool get_has_frame ()
Gets the value set by set_has_frame.
- public bool get_icon_activatable (EntryIconPosition icon_pos)
Returns whether the icon is activatable.
- public Rectangle get_icon_area (EntryIconPosition icon_pos)
Gets the area where entry’s icon at
icon_posis drawn. - public int get_icon_at_pos (int x, int y)
Finds the icon at the given position and return its index.
- public unowned Icon? get_icon_gicon (EntryIconPosition icon_pos)
Retrieves the Icon used for the icon, or null if there is no icon or if the icon was set by some other method (e.
- public unowned string? get_icon_name (EntryIconPosition icon_pos)
Retrieves the icon name used for the icon, or null if there is no icon or if the icon was set by some other method (e.
- public unowned Pixbuf? get_icon_pixbuf (EntryIconPosition icon_pos)
Retrieves the image used for the icon.
- public bool get_icon_sensitive (EntryIconPosition icon_pos)
Returns whether the icon appears sensitive or insensitive.
- public unowned string get_icon_stock (EntryIconPosition icon_pos)
Retrieves the stock id used for the icon, or null if there is no icon or if the icon was set by some other method (e.
- public ImageType get_icon_storage_type (EntryIconPosition icon_pos)
Gets the type of representation being used by the icon to store image data.
- public string? get_icon_tooltip_markup (EntryIconPosition icon_pos)
Gets the contents of the tooltip on the icon at the specified position in this.
- public string? get_icon_tooltip_text (EntryIconPosition icon_pos)
Gets the contents of the tooltip on the icon at the specified position in this.
- public unowned Border? get_inner_border ()
This function returns the entry’s inner_border property.
- public InputHints get_input_hints ()
Gets the value of the input_hints property.
- public InputPurpose get_input_purpose ()
Gets the value of the input_purpose property.
- public unichar get_invisible_char ()
Retrieves the character displayed in place of the real characters for entries with visibility set to false.
- public unowned Layout get_layout ()
Gets the Layout used to display the entry.
- public void get_layout_offsets (out int x, out int y)
Obtains the position of the Layout used to render text in the entry, in widget coordinates.
- public int get_max_length ()
Retrieves the maximum allowed length of the text in this.
- public int get_max_width_chars ()
Retrieves the desired maximum width of this , in characters.
- public bool get_overwrite_mode ()
Gets the value set by set_overwrite_mode.
- public unowned string get_placeholder_text ()
Retrieves the text that will be displayed when this is empty and unfocused
- public double get_progress_fraction ()
Returns the current fraction of the task that’s been completed.
- public double get_progress_pulse_step ()
Retrieves the pulse step set with set_progress_pulse_step.
- public unowned TabArray? get_tabs ()
Gets the tabstops that were set on the entry using set_tabs, if any.
- public unowned string get_text ()
Retrieves the contents of the entry widget.
- public void get_text_area (out Rectangle text_area)
Gets the area where the entry’s text is drawn.
- public virtual void get_text_area_size (out int x, out int y, out int width, out int height)
- public uint16 get_text_length ()
Retrieves the current length of the text in this .
- public bool get_visibility ()
Retrieves whether the text in this is visible.
- public int get_width_chars ()
Gets the value set by set_width_chars.
- public void grab_focus_without_selecting ()
Causes this to have keyboard focus.
- public bool im_context_filter_keypress (EventKey event)
Allow the Entry input method to internally handle key press and release events.
- public int layout_index_to_text_index (int layout_index)
Converts from a position in the entry’s Layout (returned by get_layout) to a position in the entry contents (returned by get_text).
- public void progress_pulse ()
Indicates that some progress is made, but you don’t know how much.
- public void reset_im_context ()
Reset the input method context of the entry if needed.
- public void set_activates_default (bool setting)
If
settingis true, pressing Enter in the this will activate the default widget for the window containing the entry. - public void set_alignment (float xalign)
Sets the alignment for the contents of the entry.
- public void set_attributes (AttrList attrs)
Sets a AttrList; the attributes in the list are applied to the entry text.
- public void set_buffer (EntryBuffer buffer)
Set the EntryBuffer object which holds the text for this widget.
- public void set_completion (EntryCompletion? completion)
Sets
completionto be the auxiliary completion object to use with this. - public void set_cursor_hadjustment (Adjustment? adjustment)
Hooks up an adjustment to the cursor position in an entry, so that when the cursor is moved, the adjustment is scrolled to show that position.
- public void set_has_frame (bool setting)
Sets whether the entry has a beveled frame around it.
- public void set_icon_activatable (EntryIconPosition icon_pos, bool activatable)
Sets whether the icon is activatable.
- public void set_icon_drag_source (EntryIconPosition icon_pos, TargetList target_list, DragAction actions)
Sets up the icon at the given position so that GTK+ will start a drag operation when the user clicks and drags the icon.
- public void set_icon_from_gicon (EntryIconPosition icon_pos, Icon? icon)
Sets the icon shown in the entry at the specified position from the current icon theme.
- public void set_icon_from_icon_name (EntryIconPosition icon_pos, string? icon_name)
Sets the icon shown in the entry at the specified position from the current icon theme.
- public void set_icon_from_pixbuf (EntryIconPosition icon_pos, Pixbuf? pixbuf)
Sets the icon shown in the specified position using a pixbuf.
- public void set_icon_from_stock (EntryIconPosition icon_pos, string? stock_id)
Sets the icon shown in the entry at the specified position from a stock image.
- public void set_icon_sensitive (EntryIconPosition icon_pos, bool sensitive)
Sets the sensitivity for the specified icon.
- public void set_icon_tooltip_markup (EntryIconPosition icon_pos, string? tooltip)
Sets
tooltipas the contents of the tooltip for the icon at the specified position. - public void set_icon_tooltip_text (EntryIconPosition icon_pos, string? tooltip)
Sets
tooltipas the contents of the tooltip for the icon at the specified position. - public void set_inner_border (Border? border)
Sets entry’s inner-border property to
border, or clears it if null is passed. - public void set_input_hints (InputHints hints)
Sets the input_hints property, which allows input methods to fine-tune their behaviour.
- public void set_input_purpose (InputPurpose purpose)
Sets the input_purpose property which can be used by on-screen keyboards and other input methods to adjust their behaviour.
- public void set_invisible_char (unichar ch)
Sets the character to use in place of the actual text when set_visibility has been called to set text visibility to false.
- public void set_max_length (int max)
Sets the maximum allowed length of the contents of the widget.
- public void set_max_width_chars (int n_chars)
Sets the desired maximum width in characters of this.
- public void set_overwrite_mode (bool overwrite)
Sets whether the text is overwritten when typing in the Entry.
- public void set_placeholder_text (string? text)
Sets text to be displayed in this when it is empty and unfocused.
- public void set_progress_fraction (double fraction)
Causes the entry’s progress indicator to “fill in” the given fraction of the bar.
- public void set_progress_pulse_step (double fraction)
Sets the fraction of total entry width to move the progress bouncing block for each call to progress_pulse.
- public void set_tabs (TabArray tabs)
Sets a TabArray; the tabstops in the array are applied to the entry text.
- public void set_text (string text)
Sets the text in the widget to the given value, replacing the current contents.
- public void set_visibility (bool visible)
Sets whether the contents of the entry are visible or not.
- public void set_width_chars (int n_chars)
Changes the size request of the entry to be about the right size for
n_charscharacters. - public int text_index_to_layout_index (int text_index)
Converts from a position in the entry contents (returned by get_text) to a position in the entry’s Layout (returned by get_layout, with text retrieved via get_text).
- public void unset_invisible_char ()
Unsets the invisible char previously set with set_invisible_char.
Signals:
- public virtual signal void activate ()
The activate signal is emitted when the user hits the Enter key.
- public virtual signal void backspace ()
The backspace signal is a keybinding signal which gets emitted when the user asks for it.
- public virtual signal void copy_clipboard ()
The copy_clipboard signal is a keybinding signal which gets emitted to copy the selection to the clipboard.
- public virtual signal void cut_clipboard ()
The cut_clipboard signal is a keybinding signal which gets emitted to cut the selection to the clipboard.
- public virtual signal void delete_from_cursor (DeleteType type, int count)
The delete_from_cursor signal is a keybinding signal which gets emitted when the user initiates a text deletion.
- public signal void icon_press (EntryIconPosition icon_pos, Event event)
The icon_press signal is emitted when an activatable icon is clicked.
- public signal void icon_release (EntryIconPosition icon_pos, Event event)
The icon_release signal is emitted on the button release from a mouse click over an activatable icon.
- public virtual signal void insert_at_cursor (string str)
The insert_at_cursor signal is a keybinding signal which gets emitted when the user initiates the insertion of a fixed string at the cursor.
- public virtual signal void insert_emoji ()
The insert_emoji signal is a keybinding signal which gets emitted to present the Emoji chooser for the
entry. - public virtual signal void move_cursor (MovementStep step, int count, bool extend_selection)
The move_cursor signal is a keybinding signal which gets emitted when the user initiates a cursor movement.
- public virtual signal void paste_clipboard ()
The paste_clipboard signal is a keybinding signal which gets emitted to paste the contents of the clipboard into the text view.
- public virtual signal void populate_popup (Menu popup)
The populate_popup signal gets emitted before showing the context menu of the entry.
- public signal void preedit_changed (string preedit)
If an input method is used, the typed text will not immediately be committed to the buffer.
- public virtual signal void toggle_overwrite ()
The toggle_overwrite signal is a keybinding signal which gets emitted to toggle the overwrite mode of the entry.
Inherited Members:
- accel_closures_changed
- activate
- add_accelerator
- add_device_events
- add_events
- add_mnemonic_label
- add_tick_callback
- adjust_baseline_allocation
- adjust_baseline_request
- adjust_size_allocation
- adjust_size_request
- app_paintable
- bind_template_callback_full
- bind_template_child_full
- button_press_event
- button_release_event
- can_activate_accel
- can_default
- can_focus
- child_focus
- child_notify
- class_path
- composite_child
- composited_changed
- compute_expand
- compute_expand_internal
- configure_event
- create_pango_context
- create_pango_layout
- damage_event
- delete_event
- destroy
- destroy_event
- destroyed
- device_is_shadowed
- direction_changed
- dispatch_child_properties_changed
- double_buffered
- drag_begin
- drag_data_delete
- drag_data_get
- drag_data_received
- drag_drop
- drag_end
- drag_failed
- drag_leave
- drag_motion
- draw
- draw_to_cairo_context
- ensure_style
- enter_notify_event
- error_bell
- event
- event_after
- events
- expand
- find_style_property
- focus
- focus_in_event
- focus_on_click
- focus_out_event
- freeze_child_notify
- get_accessible
- get_action_group
- get_allocated_baseline
- get_allocated_height
- get_allocated_size
- get_allocated_width
- get_allocation
- get_ancestor
- get_app_paintable
- get_can_default
- get_can_focus
- get_child_requisition
- get_child_visible
- get_clip
- get_clipboard
- get_composite_name
- get_css_name
- get_default_direction
- get_default_style
- get_device_enabled
- get_device_events
- get_direction
- get_display
- get_double_buffered
- get_events
- get_focus_on_click
- get_font_map
- get_font_options
- get_frame_clock
- get_halign
- get_has_tooltip
- get_has_window
- get_hexpand
- get_hexpand_set
- get_mapped
- get_margin_bottom
- get_margin_end
- get_margin_left
- get_margin_right
- get_margin_start
- get_margin_top
- get_modifier_mask
- get_modifier_style
- get_no_show_all
- get_opacity
- get_pango_context
- get_parent
- get_parent_window
- get_path
- get_pointer
- get_preferred_height
- get_preferred_height_and_baseline_for_width
- get_preferred_height_for_width
- get_preferred_height_for_width_internal
- get_preferred_height_internal
- get_preferred_size
- get_preferred_width
- get_preferred_width_for_height
- get_preferred_width_for_height_internal
- get_preferred_width_internal
- get_realized
- get_receives_default
- get_request_mode
- get_requisition
- get_root_window
- get_scale_factor
- get_screen
- get_sensitive
- get_settings
- get_size_request
- get_state
- get_state_flags
- get_style
- get_style_context
- get_support_multidevice
- get_template_child
- get_tooltip_markup
- get_tooltip_text
- get_tooltip_window
- get_toplevel
- get_valign
- get_valign_with_baseline
- get_vexpand
- get_vexpand_set
- get_visible
- get_visual
- get_window
- grab_broken_event
- grab_default
- grab_focus
- grab_notify
- halign
- has_default
- has_focus
- has_grab
- has_rc_style
- has_screen
- has_tooltip
- has_visible_focus
- height_request
- hexpand
- hexpand_set
- hide
- hide_on_delete
- hierarchy_changed
- in_destruction
- init_template
- input_shape_combine_region
- insert_action_group
- install_style_property
- install_style_property_parser
- intersect
- is_ancestor
- is_composited
- is_drawable
- is_focus
- is_sensitive
- is_toplevel
- is_visible
- key_press_event
- key_release_event
- keynav_failed
- leave_notify_event
- list_accel_closures
- list_action_prefixes
- list_mnemonic_labels
- list_style_properties
- map
- map_event
- margin
- margin_bottom
- margin_end
- margin_left
- margin_right
- margin_start
- margin_top
- mnemonic_activate
- modify_base
- modify_bg
- modify_cursor
- modify_fg
- modify_font
- modify_style
- modify_text
- motion_notify_event
- move_focus
- name
- no_show_all
- opacity
- override_background_color
- override_color
- override_cursor
- override_font
- override_symbolic_color
- parent
- parent_set
- path
- pop_composite_child
- popup_menu
- property_notify_event
- proximity_in_event
- proximity_out_event
- push_composite_child
- query_tooltip
- queue_allocate
- queue_compute_expand
- queue_draw
- queue_draw_area
- queue_draw_region
- queue_resize
- queue_resize_no_redraw
- realize
- receives_default
- region_intersect
- register_window
- remove_accelerator
- remove_mnemonic_label
- remove_tick_callback
- render_icon
- render_icon_pixbuf
- reparent
- reset_rc_styles
- reset_style
- scale_factor
- screen_changed
- scroll_event
- selection_clear_event
- selection_get
- selection_notify_event
- selection_received
- selection_request_event
- send_expose
- send_focus_change
- sensitive
- set_accel_path
- set_accessible_role
- set_accessible_type
- set_allocation
- set_app_paintable
- set_can_default
- set_can_focus
- set_child_visible
- set_clip
- set_composite_name
- set_connect_func
- set_css_name
- set_default_direction
- set_device_enabled
- set_device_events
- set_direction
- set_double_buffered
- set_events
- set_focus_on_click
- set_font_map
- set_font_options
- set_halign
- set_has_tooltip
- set_has_window
- set_hexpand
- set_hexpand_set
- set_mapped
- set_margin_bottom
- set_margin_end
- set_margin_left
- set_margin_right
- set_margin_start
- set_margin_top
- set_no_show_all
- set_opacity
- set_parent
- set_parent_window
- set_realized
- set_receives_default
- set_redraw_on_allocate
- set_sensitive
- set_size_request
- set_state
- set_state_flags
- set_style
- set_support_multidevice
- set_template
- set_template_from_resource
- set_tooltip_markup
- set_tooltip_text
- set_tooltip_window
- set_valign
- set_vexpand
- set_vexpand_set
- set_visible
- set_visual
- set_window
- shape_combine_region
- show
- show_all
- show_help
- show_now
- size_allocate
- size_allocate_with_baseline
- size_request
- state_changed
- state_flags_changed
- style
- style_attach
- style_get
- style_get_property
- style_get_valist
- style_set
- style_updated
- thaw_child_notify
- tooltip_markup
- tooltip_text
- touch_event
- translate_coordinates
- trigger_tooltip_query
- unmap
- unmap_event
- unparent
- unrealize
- unregister_window
- unset_state_flags
- valign
- vexpand
- vexpand_set
- visibility_notify_event
- visible
- width_request
- window_state_event