Class OptionMenu

All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") public final class OptionMenu extends GObject

Represents the dropdown menu of a select element in a WebKitWebView.

When a select element in a WebKitWebView needs to display a dropdown menu, the signal WebKitWebView::show-option-menu is emitted, providing a WebKitOptionMenu with the WebKitOptionMenuItems that should be displayed.

Since:
2.18
  • Constructor Details

    • OptionMenu

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

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

    • getType

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

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

      protected OptionMenu 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 GObject
      Returns:
      the instance as if it were its parent type
    • activateItem

      public void activateItem(int index)

      Activates the WebKitOptionMenuItem at index in menu.

      Activating an item changes the value of the element making the item the active one. You are expected to close the menu with webkit_option_menu_close() after activating an item, calling this function again will have no effect.

      Parameters:
      index - the index of the item
      Since:
      2.18
    • close

      public void close()

      Request to close a WebKitOptionMenu.

      This emits WebKitOptionMenu::close signal. This function should always be called to notify WebKit that the associated menu has been closed. If the menu is closed and neither webkit_option_menu_select_item() nor webkit_option_menu_activate_item() have been called, the element value remains unchanged.

      Since:
      2.18
    • getEvent

      public Event getEvent()
      Gets the GdkEvent that triggered the dropdown menu. If this OptionMenu was not triggered by a user interaction, like a mouse click, null is returned.
      Returns:
      the menu event or null.
      Since:
      2.40
    • getItem

      public OptionMenuItem getItem(int index)
      Returns the WebKitOptionMenuItem at index in menu.
      Parameters:
      index - the index of the item
      Returns:
      a WebKitOptionMenuItem of menu.
      Since:
      2.18
    • getNItems

      public int getNItems()
      Gets the length of the menu.
      Returns:
      the number of WebKitOptionMenuItems in this OptionMenu
      Since:
      2.18
    • selectItem

      public void selectItem(int index)

      Selects the WebKitOptionMenuItem at index in menu.

      Selecting an item changes the text shown by the combo button, but it doesn't change the value of the element. You need to explicitly activate the item with webkit_option_menu_select_item() or close the menu with webkit_option_menu_close() in which case the currently selected item will be activated.

      Parameters:
      index - the index of the item
      Since:
      2.18
    • onClose

      Emitted when closing a WebKitOptionMenu is requested. This can happen when the user explicitly calls webkit_option_menu_close() or when the element is detached from the current page.
      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      Since:
      2.18
      See Also:
    • emitClose

      public void emitClose()
      Emits the "close" signal. See onClose(OptionMenu.CloseCallback).
    • builder

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