org.gnome.gtk

## Class Entry

- Object
- - org.freedesktop.bindings.Pointer
  - - org.freedesktop.bindings.Proxy
    - - org.gnome.glib.Object
      - - org.gnome.gtk.Widget
        - - org.gnome.gtk.Entry

- All Implemented Interfaces:
    CellEditable, Editable
  Direct Known Subclasses:
    SpinButton

      public class Entry
      extends Widget
      implements Editable, CellEditable

  A data entry field allowing the user to input a single line of text.
  Since:
    4.0.3
  Author:
    Sebastian Mancke, Andrew Cowie, Guillaume Mazoyer

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static interface` | `Entry.Activate` The `Entry.Activate` signal occurs when the user presses `Enter` or `Return` in an Entry.
    `static interface` | `Entry.Changed` The signal emitted when the text in the Entry has changed.
    `static interface` | `Entry.IconPress` Emitted when an activatable icon is clicked.
    `static interface` | `Entry.IconRelease` Emitted on the button release from a mouse click over an activatable icon.

    - ### Nested classes/interfaces inherited from class org.gnome.gtk.Widget

      `Widget.ButtonPressEvent, Widget.ButtonReleaseEvent, Widget.Destroy, Widget.Draw, Widget.EnterNotifyEvent, Widget.FocusInEvent, Widget.FocusOutEvent, Widget.Hide, Widget.KeyPressEvent, Widget.KeyReleaseEvent, Widget.LeaveNotifyEvent, Widget.MapEvent, Widget.MotionNotifyEvent, Widget.PopupMenu, Widget.QueryTooltip, Widget.ScrollEvent, Widget.SizeAllocate, Widget.UnmapEvent, Widget.VisibilityNotifyEvent`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Entry()` Construct a new Entry
    `Entry(String text)` Construct a new Entry, initialized with the specified text

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `connect(Editable.Changed handler)` Connect a `Editable.Changed` handler.
    `void` | `connect(Entry.Activate handler)` Connects an `Entry.Activate` handler to the Widget.
    `void` | `connect(Entry.Changed handler)` Connect a `Entry.Changed` handler.
    `void` | `connect(Entry.IconPress handler)` Hook up the `Entry.IconPress` handler.
    `void` | `connect(Entry.IconRelease handler)` Hook up the `Entry.IconRelease` handler.
    `EntryCompletion` | `getCompletion()` Returns the current `EntryCompletion` object which is currently used by the `Entry`.
    `boolean` | `getIconActivatable(EntryIconPosition position)` Return `true` if the icon at the given `position` is activatable.
    `int` | `getIconAtPos(int x, int y)` Find the icon at the given position and return its index.
    `Icon` | `getIconIcon(EntryIconPosition position)` Retrieves the named Icon used for illustrating icon at `position` on this Entry.
    `Pixbuf` | `getIconPixbuf(EntryIconPosition position)` Retrieves the image used for the icon as a `Pixbuf`.
    `boolean` | `getIconSensitive(EntryIconPosition position)` Return `true` if the icon at the given `position` is sensitive.
    `Stock` | `getIconStock(EntryIconPosition position)` Retrieves the image used for the icon as a `Stock` item.
    `ImageType` | `getIconStorageType(EntryIconPosition position)` Get the type used by the icon to store image data.
    `String` | `getIconTooltipMarkup(EntryIconPosition position)` Return the note that is displayed when the mouse pointer is over the icon.
    `String` | `getIconTooltipText(EntryIconPosition position)` Return the note that is displayed when the mouse pointer is over the icon.
    `int` | `getMaxLength()` Returns the current maximum width, in characters, the text in the Entry is allowed to be.
    `boolean` | `getOverwriteMode()` Get the value previously set with `setOverwriteMode()`.
    `int` | `getPosition()` Retrieves the current cursor position.
    `double` | `getProgressFraction()` Get the current progress fraction of the `Entry`.
    `double` | `getProgressPulseStep()` Get the current progress pulse step of the `Entry`.
    `int` | `getSelectionBoundsEnd()` Retrieves the selection end position of the Editable.
    `int` | `getSelectionBoundsStart()` Retrieves the selection start position of the Editable.
    `String` | `getText()` Get the text currently showing in the Entry.
    `char` | `getTextLength()` Get the length of the text currently showing in the Entry.
    `boolean` | `getVisibility()` Is text in the Entry are visible, or hidden by an obscuring character?
    `void` | `progressPulse()` Cause the `Entry`'s progress indicator to enter "activity mode", used to indicate that the application is making progress but in a way that can't be strictly quantized.
    `void` | `selectRegion(int start, int end)` Select a region of the text in this Editable.
    `void` | `setAlignment(float xalign)` Set the alignment of the the text being displayed in the Entry.
    `void` | `setCompletion(EntryCompletion completion)` Set the completion object to use with this Entry.
    `void` | `setEditable(boolean editable)` Set whether the text in the Entry can be change by the user.
    `void` | `setHasFrame(boolean setting)` Set whether the Entry has a bevelled frame around it or not.
    `void` | `setIconActivatable(EntryIconPosition position, boolean setting)` Set whether the icon at the given `position` is activatable or not.
    `void` | `setIconFromIcon(EntryIconPosition position, Icon icon)` Cause the Entry to have an icon at the given `position` using an Icon from the current icon theme.
    `void` | `setIconFromPixbuf(EntryIconPosition position, Pixbuf pixbuf)` Set the icon to a given `position` using a `Pixbuf`.
    `void` | `setIconFromStock(EntryIconPosition position, Stock stock)` Set the icon to a given `position` using a `Stock` item.
    `void` | `setIconSensitive(EntryIconPosition position, boolean setting)` Set whether the icon at the given `position` should be sensitive or insensitive.
    `void` | `setIconTooltipMarkup(EntryIconPosition position, String markup)` Set the note (with Pango markup) that will be displayed when the mouse pointer will be over the icon.
    `void` | `setIconTooltipText(EntryIconPosition position, String text)` Set the note (without Pango markup) that will be displayed when the mouse pointer will be over the icon.
    `void` | `setInnerBorder(int left, int right, int top, int bottom)` Set the padding between the text entry control itself, and the surrounding decoration.
    `void` | `setInvisibleChar(char replacement)` Change the character used to obscure text when `visibility` is `false`.
    `void` | `setMaxLength(int max)` Specify the maximum number of characters the user is allowed to enter.
    `void` | `setOverwriteMode(boolean setting)` Set whether the text should be overwritten when typing in the Entry.
    `void` | `setPosition(int position)` Set the position of the cursor in this Editable.
    `void` | `setProgressFraction(double fraction)` Set the fraction of the progress that shows the `Entry` as "filled-in".
    `void` | `setProgressPulseStep(double fraction)` Set the progress pulse step of the `Entry`.
    `void` | `setText(String text)` Replace the current contents of the Entry with the supplied text.
    `void` | `setVisibility(boolean setting)` Set whether the text in the entry is visible or obscured.
    `void` | `setWidthChars(int width)` Request that the width of this Entry be wide enough for a given number of characters.

    - ### Methods inherited from class org.gnome.gtk.Widget

      `activate, addEvents, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, destroy, getAllocatedHeight, getAllocatedWidth, getAllocation, getCanDefault, getCanFocus, getHasFocus, getName, getParent, getPreferredHeightForWidthMinimum, getPreferredHeightForWidthNatural, getPreferredHeightMinimum, getPreferredHeightNatural, getPreferredWidthForHeightMinimum, getPreferredWidthForHeightNatural, getPreferredWidthMinimum, getPreferredWidthNatural, getRequestMode, getRequisition, getSensitive, getStyleContext, getToplevel, getWindow, grabAdd, grabDefault, grabFocus, grabRemove, hide, isSensitive, overrideBackground, overrideColor, overrideFont, queueDraw, queueDrawArea, realize, setAlignHorizontal, setAlignVertical, setCanDefault, setCanFocus, setEvents, setExpandHorizontal, setExpandVertical, setName, setSensitive, setSizeRequest, setTooltipMarkup, setTooltipText, show, showAll`

    - ### Methods inherited from class org.freedesktop.bindings.Pointer

      `toString`

    - ### Methods inherited from class Object

      `equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### Entry

          public Entry()

      Construct a new Entry
      Since:
        4.0.3

    - #### Entry

          public Entry(String text)

      Construct a new Entry, initialized with the specified text
      Since:
        4.0.3

  - ### Method Detail

    - #### connect

          public void connect(Editable.Changed handler)

      Connect a `Editable.Changed` handler. Use `connect(Entry.Changed)` instead, as it saves you having to cast the `source` parameter.
      Specified by:
        `connect` in interface `Editable`
      Since:
        4.0.6

    - #### connect

          public void connect(Entry.Activate handler)

      Connects an `Entry.Activate` handler to the Widget.
      Since:
        4.0.3

    - #### connect

          public void connect(Entry.Changed handler)

      Connect a `Entry.Changed` handler.
      Since:
        4.1.1

    - #### connect

          public void connect(Entry.IconPress handler)

      Hook up the `Entry.IconPress` handler.
      Since:
        4.0.13

    - #### connect

          public void connect(Entry.IconRelease handler)

      Hook up the `Entry.IconRelease` handler.
      Since:
        4.0.13

    - #### getCompletion

          public EntryCompletion getCompletion()

      Returns the current `EntryCompletion` object which is currently used by the `Entry`.
      Since:
        4.0.12

    - #### getIconActivatable

          public boolean getIconActivatable(EntryIconPosition position)

      Return `true` if the icon at the given `position` is activatable.
      Since:
        4.0.13

    - #### getIconAtPos

          public int getIconAtPos(int x,
                         int y)

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

      If `x` or `y` are not inside an icon, `-1` will be returned.

      Since:
        4.0.13

    - #### getIconIcon

          public Icon getIconIcon(EntryIconPosition position)

      Retrieves the named Icon used for illustrating icon at `position` on this Entry.

      A `null` value will be returned if the icon was not set from an named Icon.

      Since:
        4.0.17

    - #### getIconPixbuf

          public Pixbuf getIconPixbuf(EntryIconPosition position)

      Retrieves the image used for the icon as a `Pixbuf`.

      A `null` value will be returned if no icon is set for this `position`.``

      Since:
        4.0.13

    - #### getIconSensitive

          public boolean getIconSensitive(EntryIconPosition position)

      Return `true` if the icon at the given `position` is sensitive.
      Since:
        4.0.13

    - #### getIconStock

          public Stock getIconStock(EntryIconPosition position)

      Retrieves the image used for the icon as a `Stock` item.

      A `null` value will be returned if the icon was not set from a `Stock` item.

      Since:
        4.0.13

    - #### getIconStorageType

          public ImageType getIconStorageType(EntryIconPosition position)

      Get the type used by the icon to store image data.
      Since:
        4.0.13

    - #### getIconTooltipMarkup

          public String getIconTooltipMarkup(EntryIconPosition position)

      Return the note that is displayed when the mouse pointer is over the icon.
      Since:
        4.0.13

    - #### getIconTooltipText

          public String getIconTooltipText(EntryIconPosition position)

      Return the note that is displayed when the mouse pointer is over the icon.
      Since:
        4.0.13

    - #### getMaxLength

          public int getMaxLength()

      Returns the current maximum width, in characters, the text in the Entry is allowed to be.
      Since:
        4.0.3

    - #### getOverwriteMode

          public boolean getOverwriteMode()

      Get the value previously set with `setOverwriteMode()`.
      Since:
        4.0.13

    - #### getPosition

          public int getPosition()

      Description copied from interface: `Editable`
      Retrieves the current cursor position. Returns the position of the cursor. The cursor is displayed before the character with the given (base 0) index in the widget. The value will be less than or equal to the number of characters in the widget.
      Specified by:
        `getPosition` in interface `Editable`

    - #### getProgressFraction

          public double getProgressFraction()

      Get the current progress fraction of the `Entry`.
      Since:
        4.0.13

    - #### getProgressPulseStep

          public double getProgressPulseStep()

      Get the current progress pulse step of the `Entry`.
      Since:
        4.0.13

    - #### getSelectionBoundsEnd

          public int getSelectionBoundsEnd()

      Description copied from interface: `Editable`
      Retrieves the selection end position of the Editable. If no text was selected both `getSelectionBoundsStart()` and `getSelectionBoundsEnd()` will be identical.
      Specified by:
        `getSelectionBoundsEnd` in interface `Editable`

    - #### getSelectionBoundsStart

          public int getSelectionBoundsStart()

      Description copied from interface: `Editable`
      Retrieves the selection start position of the Editable. If no text was selected both `getSelectionBoundsStart()` and `getSelectionBoundsEnd()` will be identical.
      Specified by:
        `getSelectionBoundsStart` in interface `Editable`

    - #### getText

          public String getText()

      Get the text currently showing in the Entry. This is typically the most significant method as it is the one you use to get the result of the user's activity upon receiving a `Entry.Activate` signal.
      Since:
        4.0.3

    - #### getTextLength

          public char getTextLength()

      Get the length of the text currently showing in the Entry.
      Since:
        4.0.13

    - #### getVisibility

          public boolean getVisibility()

      Is text in the Entry are visible, or hidden by an obscuring character? Returns `true` if characters entered are visible, `false` if obscured.
      Since:
        4.0.12

    - #### progressPulse

          public void progressPulse()

      Cause the `Entry`'s progress indicator to enter "activity mode", used to indicate that the application is making progress but in a way that can't be strictly quantized.
      Since:
        4.0.13

    - #### selectRegion

          public void selectRegion(int start,
                          int end)

      Description copied from interface: `Editable`
      Select a region of the text in this Editable. The characters between `start` up to but not including `end` will be selected.

      Calling `selectRegion(0, 0)` will remove the selection (although that will only happen if some other Widget has the focus; in Windows where there is only one control the user can manipulate an Entry will end up selected no matter what).

      Specified by:
        `selectRegion` in interface `Editable`
        `end` - If negative, then the selection will be from `start` to the end of the text in the Editable.

    - #### setAlignment

          public void setAlignment(float xalign)

      Set the alignment of the the text being displayed in the Entry.
      Parameters:
        `xalign` - A value from `0.0f` for fully left-aligned through `1.0f` for fully right-aligned. You can use the constants `LEFT`, `CENTER` and `RIGHT` in Alignment for convenience if you like. No, this has nothing to do with politics.
      Since:
        4.0.6

    - #### setCompletion

          public void setCompletion(EntryCompletion completion)

      Set the completion object to use with this Entry.

      Completion is a mechanism whereby pre-populated suggestions can be offered to the user, allowing for faster data entry in some circumstances.

      All configuration of the completion mechanism is done using `EntryCompletion`'s methods, so see there for details.

      Since:
        4.0.12

    - #### setEditable

          public void setEditable(boolean editable)

      Set whether the text in the Entry can be change by the user.
      Since:
        4.0.3

    - #### setHasFrame

          public void setHasFrame(boolean setting)

      Set whether the Entry has a bevelled frame around it or not. The default (as you will be well accustomed to seeing) is `true` .

      As this decoration is a strong visual cue for users to realize that they are able to enter text into a given control, your are discouraged from turning it off unless you really need to minutely control placement; in that case, see also `setInnerBorder()`.

      Since:
        4.0.8

    - #### setIconActivatable

          public void setIconActivatable(EntryIconPosition position,
                                boolean setting)

      Set whether the icon at the given `position` is activatable or not.
      Since:
        4.0.13

    - #### setIconFromIcon

          public void setIconFromIcon(EntryIconPosition position,
                             Icon icon)

      Cause the Entry to have an icon at the given `position` using an Icon from the current icon theme. If `name` is `null`, no icon will be shown. If for whatever reason the icon lookup fails, a "broken image" icon will be used instead.
      Since:
        4.0.17

    - #### setIconFromPixbuf

          public void setIconFromPixbuf(EntryIconPosition position,
                               Pixbuf pixbuf)

      Set the icon to a given `position` using a `Pixbuf`. If `pixbuf` is `null`, no icon will be shown.
      Since:
        4.0.13

    - #### setIconFromStock

          public void setIconFromStock(EntryIconPosition position,
                              Stock stock)

      Set the icon to a given `position` using a `Stock` item. If `stock` is `null`, no icon will be shown.
      Since:
        4.0.13

    - #### setIconSensitive

          public void setIconSensitive(EntryIconPosition position,
                              boolean setting)

      Set whether the icon at the given `position` should be sensitive or insensitive.
      Since:
        4.0.13

    - #### setIconTooltipMarkup

          public void setIconTooltipMarkup(EntryIconPosition position,
                                  String markup)

      Set the note (with Pango markup) that will be displayed when the mouse pointer will be over the icon.
      Since:
        4.0.13

    - #### setIconTooltipText

          public void setIconTooltipText(EntryIconPosition position,
                                String text)

      Set the note (without Pango markup) that will be displayed when the mouse pointer will be over the icon. The `text` string should be in plain text (without any Pango markup).
      Since:
        4.0.13

    - #### setInnerBorder

          public void setInnerBorder(int left,
                            int right,
                            int top,
                            int bottom)

      Set the padding between the text entry control itself, and the surrounding decoration. This overrides the inner-border style property set by the theme.

      Ordinarily you shouldn't need this; in general you should leave things alone so that Entries appear uniform across the user's desktop. This is provided for the rare cases that minute positioning control is required (think of what goes on when you edit text in a CellRendererText) it is possible to do so.

      Since:
        4.0.8

    - #### setInvisibleChar

          public void setInvisibleChar(char replacement)

      Change the character used to obscure text when `visibility` is `false`.
      Parameters:
        `replacement` - The new character to be used to obscure text. A value of `0` will cause no feedback to displayed at all when the user is typing in the Entry.
      Since:
        4.0.3

    - #### setMaxLength

          public void setMaxLength(int max)

      Specify the maximum number of characters the user is allowed to enter. Note that if the current text in the Entry is longer than the specified length, the contents will be truncated!
      Parameters:
        `max` - A value of `0` indicates no maximum length.
      Since:
        4.0.3

    - #### setOverwriteMode

          public void setOverwriteMode(boolean setting)

      Set whether the text should be overwritten when typing in the Entry.
      Since:
        4.0.13

    - #### setPosition

          public void setPosition(int position)

      Description copied from interface: `Editable`
      Set the position of the cursor in this Editable. The cursor will be put before the character at the position indicated.
      Specified by:
        `setPosition` in interface `Editable`
      Parameters:
        `position` - The value given must be less than or equal to the number of characters currently in the Editable field. Supplying a value of `-1` will cause the cursor to move to a position after the last character in the text.

    - #### setProgressFraction

          public void setProgressFraction(double fraction)

      Set the fraction of the progress that shows the `Entry` as "filled-in".
      Since:
        4.0.13

    - #### setProgressPulseStep

          public void setProgressPulseStep(double fraction)

      Set the progress pulse step of the `Entry`.
      Since:
        4.0.13

    - #### setText

          public void setText(String text)

      Replace the current contents of the Entry with the supplied text.
      Since:
        4.0.3

    - #### setVisibility

          public void setVisibility(boolean setting)

      Set whether the text in the entry is visible or obscured. This is typically used for password fields. Use `true` for showing and `false` for hiding input characters.

      When set to be not visible, characters entered are shown with a `'*'` instead. This default can be changed with `setInvisibleChar()`.

      Since:
        4.0.12

    - #### setWidthChars

          public void setWidthChars(int width)

      Request that the width of this Entry be wide enough for a given number of characters.

      As with all font related operations, there are a number of competing approximations involved. In particular, this method operates by influencing the size requested by this Widget; the box packing model will still have the final say in the size-allocation phase.

      See also Label's `setWidthChars()`; the challenges and constraints involved are similar.

      Parameters:
        `width` - A setting of `-1` will return the Entry to normal sizing behaviour.
      Since:
        4.0.6