Class PasswordEntry

All Implemented Interfaces:
Accessible, Buildable, ConstraintTarget, Editable, Proxy

@Generated("org.javagi.JavaGI") public class PasswordEntry extends Widget implements Accessible, Buildable, ConstraintTarget, Editable

A single-line text entry widget for entering passwords and other secrets.

An example GtkPasswordEntry

It does not show its contents in clear text, does not allow to copy it to the clipboard, and it shows a warning when Caps Lock is engaged. If the underlying platform allows it, GtkPasswordEntry will also place the text in a non-pageable memory area, to avoid it being written out to disk by the operating system.

Optionally, it can offer a way to reveal the contents in clear text.

GtkPasswordEntry provides only minimal API and should be used with the Editable API.

CSS Nodes

entry.password
╰── text
    ├── image.caps-lock-indicator
    ┊

GtkPasswordEntry has a single CSS node with name entry that carries a .passwordstyle class. The text Css node below it has a child with name image and style class .caps-lock-indicator for the Caps Lock icon, and possibly other children.

Accessibility

GtkPasswordEntry uses the Gtk.AccessibleRole.text_box role.

  • Constructor Details

    • PasswordEntry

      public PasswordEntry(MemorySegment address)
      Create a PasswordEntry instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • PasswordEntry

      public PasswordEntry()
      Create a new PasswordEntry.
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the PasswordEntry class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • asParent

      protected PasswordEntry asParent()
      Return this instance as if it were its parent type. Comparable to the Java super keyword, but ensures the parent typeclass is also used in native code.
      Overrides:
      asParent in class Widget
      Returns:
      the instance as if it were its parent type
    • getExtraMenu

      public @Nullable MenuModel getExtraMenu()
      Gets the menu model set with gtk_password_entry_set_extra_menu().
      Returns:
      the menu model
    • getShowPeekIcon

      public boolean getShowPeekIcon()
      Returns whether the entry is showing an icon to reveal the contents.
      Returns:
      true if an icon is shown
    • setExtraMenu

      public void setExtraMenu(@Nullable MenuModel model)
      Sets a menu model to add when constructing the context menu for entry.
      Parameters:
      model - a GMenuModel
    • setShowPeekIcon

      public void setShowPeekIcon(boolean showPeekIcon)

      Sets whether the entry should have a clickable icon to reveal the contents.

      Setting this to false also hides the text again.

      Parameters:
      showPeekIcon - whether to show the peek icon
    • onActivate

      Emitted when the entry is activated.

      The keybindings for this signal are all forms of the Enter key.

      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      See Also:
    • emitActivate

      public void emitActivate()
      Emits the "activate" signal. See onActivate(PasswordEntry.ActivateCallback).
    • builder

      public static PasswordEntry.Builder<? extends PasswordEntry.Builder> builder()
      A PasswordEntry.Builder object constructs a PasswordEntry with the specified properties. Use the various set...() methods to set properties, and finish construction with PasswordEntry.Builder.build().
      Returns:
      the builder object