Crea  Modifica  FrontPage  Indici  Cerca  Ultime modifiche  History  RSS  Login

Gtk::Entry

class Gtk::Entry

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

<URL:http://developer.gnome.org/doc/API/2.0/gtk/entry.png>

Class Methods

Gtk::Entry.new
Creates a new Gtk::Entry widget.

Instance Methods

activates_default?
Retrieves the value set by Gtk::Entry#activates_default=.
  • Returns: true if the entry will activate the default widget.
activates_default=(setting)
If setting is true, pressing Enter in the entry will activate the default widget for the window containing the entry. This usually means that the dialog box containing the entry will be closed, since the default widget is usually one of the dialog buttons. (For experts: if setting is true, the entry calls Gtk::Window#activate_default on the window containing the entry, in the default handler for the "activate" signal.)
  • setting: true to activate window's default widget on Enter keypress
  • Returns: setting.
set_activates_default(setting)
Same as Gtk::Entry#activates_default=.
  • setting: true to activate window's default widget on Enter keypress
  • Returns: self.
cursor_position
Retrieves the current cursor position. See Gtk::Editable#position.
editable?
Retrieves if the user can edit the text in the editable widget or not. See Gtk::Editable#editable?.
  • Returns: true if the user can edit the text, otherwise false.
editable=(editable)
Determines if the user can edit the text in the editable widget or not.
  • editable: true if the user can edit the text, otherwise false.
  • Returns: editable
set_editable(editable)
Same as Gtk::Entry#editable=.
  • editable: true if the user can edit the text, otherwise false.
  • Returns: self
has_frame?
Gets the value set by Gtk::Entry#has_frame=.
  • Returns: whether the entry has a beveled frame
has_frame=(setting)
Sets whether the entry has a beveled frame around it.
  • setting: new value
  • Returns: setting
set_has_frame(setting)
Same as Gtk::Entry#has_frame=.
  • setting: new value
  • Returns: setting
inner_border
This method returns the entry's inner-border property. See Gtk::Entry#inner_border= for more information. Since 2.10
  • Returns: the entry's Gtk::Border, or nil if none was set.
inner_border=(inner_border)
Sets entry's inner-border property to border, or clears it if nil is passed. The inner-border is the area around the entry's text, but inside its frame. If set, this property overrides the inner-border style property. Overriding the style-provided border is useful when you want to do in-place editing of some text in a canvas or list widget, where pixel-exact positioning of the entry is important. Sets the Border between text and frame. Overrides the inner-border style property. Since 2.10
  • inner_border: Gtk::Border between text and frame, otherwise nil. Overrides the inner-border style property
  • Returns: inner_border
set_inner_border(inner_border)
Same as inner_border=. Since 2.10
  • inner_border: Gtk::Border between text and frame, otherwise nil. Overrides the inner-border style property
  • Returns: self
invisible_char
Retrieves the character displayed in place of the real characters for entries with visibility set to false. See Gtk::Entry#invisible_char=.
  • Returns: the current invisible char, or 0, if the entry does not show invisible text at all.
invisible_char=(ch)
Sets the character to use in place of the actual text when Gtk::Entry#visibility= has been called to set text visibility to false. i.e. this is the character used in "password mode" to show the user how many characters have been typed. The default invisible char is an asterisk ('*'). 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.
  • ch: a Unicode character(Number)
  • Returns: ch
set_invisible_char(ch)
Same as Gtk::Entry#invisible_char=
  • ch: a Unicode character(Number)
  • Returns: self
xalign
Gets the value set by Gtk::Entry#xalign=. Since 2.4
  • Returns: the alignment
xalign=(xalign)
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. Since 2.4
  • xalign: The horizontal alignment, from 0 (left) to 1 (right). Reversed for RTL layouts
  • Returns: xalign
set_xalign(xalign)
Same as Gtk::Entry#xalign=. Since 2.4
  • xalign: The horizontal alignment, from 0 (left) to 1 (right). Reversed for RTL layouts
  • Returns: self
layout
Gets the Pango::Layout used to display the entry. The layout is useful to e.g. convert text positions to pixel positions, in combination with Gtk::Entry#layout_offsets. The returned layout is owned by the entry so need not be freed by the caller.
layout_offsets
Obtains the position of the Pango::Layout used to render text in the entry, in widget coordinates. Useful if you want to line up the text in an entry with some other text, e.g. when using the entry to implement editable cells in a sheet widget. Also useful to convert mouse events into coordinates inside the Pango::Layout, e.g. to take some action if some part of the entry text is clicked. Note that as the user scrolls around in the entry the offsets will change; you'll need to connect to the "notify::scroll_offset" signal to track this. Remember when using the Pango::Layout methods you need to convert to and from pixels using Pango#pixels() or Pango::SCALE.
  • Returns: [x, y]
    • x: location to store X offset of layout, or nil
    • y: location to store Y offset of layout, or nil
max_length
Retrieves the maximum allowed length of the text in entry. See Gtk::Entry#max_length=.
  • Returns: the maximum allowed number of characters in Gtk::Entry, or 0 if there is no maximum.
max_length=(length)
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.
  • length: the maximum length of the entry, or 0 for no maximum. (other than the maximum length of entries.) The value passed in will be clamped to the range 0-65536.
  • Returns: length
set_max_length(length)
Same as Gtk::Entry#max_length=.
  • length: the maximum length of the entry, or 0 for no maximum. (other than the maximum length of entries.) The value passed in will be clamped to the range 0-65536.
  • Returns: self
scroll_offset
Retrieves the number of pixels of the entry scrolled off the screen to the left.
  • Returns: the offset value.
selection_bound
Retrieves the position of the opposite end of the selection from the cursor in chars.
  • Returns: the position.
text
Retrieves the contents of the entry.
  • Returns: the contents of the entry.
text=(text)
Sets the contents of the entry.
  • text: the contents of the entry.
  • Returns: text
set_text(text)
Same as Gtk::Entry#text=.
  • text: the contents of the entry.
  • Returns: self
visibility?
Retrieves whether the text in entry is visible. See Gtk::Entry#visibility=.
  • Returns: true if the text is currently visible
visibility=(visible)
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. The default invisible char is the asterisk '*', but it can be changed with Gtk::Entry#invisible_char=.
  • visible: true if the contents of the entry are displayed as plaintext.
  • Returns: visible
set_visibility(visible)
Same as Gtk::Entry#visibility=.
  • visible: true if the contents of the entry are displayed as plaintext.
  • Returns: self
width_chars
Gets the value set by Gtk::Entry#width_chars=.
  • Returns: number of chars to request space for, or negative if unset
width_chars=(n_chars)
Changes the size request of the entry to be about the right size for n_chars characters. Note that it changes the size request, the size can still be affected by how you pack the widget into containers. If n_chars is -1, the size reverts to the default entry size.
  • n_chars : width in chars
  • Returns: n_chars
set_width_chars(n_chars)
Same as Gtk::Entry#width_chars=.
  • n_chars : width in chars
  • Returns: n_chars
completion
Returns the auxiliary completion object currently in use by entry. Since 2.4
completion=(completion)
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. Since 2.4
set_completion(completion)
Same as Gtk::Entry#completion=. Since 2.4
truncate_multiline?
Gets the value whether to truncate multiline pastes to one line. or not.
  • Returns: true if to truncate multiline pastes to one line.
truncate_multiline=(val)
Sets the value whether to truncate multiline pastes to one line. or not.
  • val: true if to truncate multiline pastes to one line.
  • Returns: val
set_truncate_multiline(val)
Same as truncate_multiline=.
  • val: true if to truncate multiline pastes to one line.
  • Returns: self

Properties

activates-default: true or false (Read/Write)
Whether to activate the default widget (such as the default button in a dialog) when Enter is pressed
  • Default value: false
cursor-position: Integer (Read)
The current position of the insertion cursor in chars
  • Allowed values: [0,65535]
  • Default value: 0
editable: true or false (Read/Write)
Whether the entry contents can be edited
  • Default value: true
has-frame: true or false (Read/Write)
false removes outside bevel from entry
  • Default value: true
inner-border: Gtk::Border (Read/Write)
Border between text and frame. Overrides the inner-border style property Since 2.10
invisible-char: Integer (Read/Write)
The character to use when masking entry contents (in "password mode")
  • Default value: '*'
max-length: Integer (Read/Write)
Maximum number of characters for this entry. Zero if no maximum
  • Allowed values: [0,65535]
  • Default value: 0
scroll-offset: Integer (Read)
Number of pixels of the entry scrolled off the screen to the left
  • Allowed values: >= 0
  • Default value: 0
selection-bound: Integer (Read)
The position of the opposite end of the selection from the cursor in chars
  • Allowed values: [0,65535]
  • Default value: 0
text: String (Read/Write)
The contents of the entry
  • Default value: ""
truncate-multiline: true or false (Read/Write)
Whether to truncate multiline pastes to one line.
  • Default value: false
visibility: true or false (Read/Write)
false displays the "invisible char" instead of the actual text (password mode)
  • Default value: true
width-chars: Integer (Read/Write)
Number of characters to leave space for in the entry
  • Allowed values: >= -1
  • Default value: -1
xalign: Float (Read/Write)
The horizontal alignment, from 0 (left) to 1 (right). Reversed for RTL layouts Since 2.4
  • Allowed values: [0,1]
  • Default value: 0

Style Properties

inner-border: Gtk::Border (Read)
Border between text and frame. Since 2.10

Signals

activate: self
Emit when return key is pressed.
copy-clipboard: self
cut-clipboard: self
delete-from-cursor: self, delete_type, position
insert-at-cursor: self, text
Doesn't this work?
move-cursor: self, step, count, extend_selection
Emits when cursor(direction) keys are pressed.
  • self: Gtk::Entry
  • step: GtkMovementStep
  • count: Move count. +1 is order direction, -1 is opposite order.
  • extend_selection: true if it extends selection or false.
paste-clipboard: self
populate-popup: self, menu
Emits when right click on the Gtk::Entry.
toggle-overwrite: self
Emits when overwrite key is pressed.
  • 2007-03-01 Added methods for 2.10. - Masao
  • 2004-12-15 Added method for 2.4, improved Propeties section to show allowed/default values. - Masao
  • 2004-05-25 Added method for 2.4 - Masao
  • 2003-04-01 Initial upload - Masao