:right-sidebar: True OptionMenu =================================================================== .. currentmodule:: gi.repository.WebKit .. versionadded:: 2.18 .. class:: OptionMenu(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.GObject.Object` Represents the dropdown menu of a ``select`` element in a :obj:`~gi.repository.WebKit.WebView`\. When a select element in a :obj:`~gi.repository.WebKit.WebView` needs to display a dropdown menu, the signal :obj:`~gi.repository.WebKit.WebView`\::show-option-menu is emitted, providing a WebKitOptionMenu with the :obj:`~gi.repository.WebKit.OptionMenuItem`\s that should be displayed. Methods ------- .. rst-class:: interim-class .. class:: OptionMenu :no-index: .. method:: activate_item(index: int) -> None Activates the :obj:`~gi.repository.WebKit.OptionMenuItem` 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 :func:`~gi.repository.WebKit.OptionMenu.close` after activating an item, calling this function again will have no effect. .. versionadded:: 2.18 :param index: the index of the item .. method:: close() -> None Request to close a :obj:`~gi.repository.WebKit.OptionMenu`\. 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 :func:`~gi.repository.WebKit.OptionMenu.select_item` nor :func:`~gi.repository.WebKit.OptionMenu.activate_item` have been called, the element value remains unchanged. .. versionadded:: 2.18 .. method:: get_event() -> ~gi.repository.Gdk.Event Gets the :obj:`~gi.repository.Gdk.Event` that triggered the dropdown menu. If ``menu`` was not triggered by a user interaction, like a mouse click, :const:`None` is returned. .. versionadded:: 2.40 .. method:: get_item(index: int) -> ~gi.repository.WebKit.OptionMenuItem Returns the :obj:`~gi.repository.WebKit.OptionMenuItem` at ``index`` in ``menu``\. .. versionadded:: 2.18 :param index: the index of the item .. method:: get_n_items() -> int Gets the length of the ``menu``\. .. versionadded:: 2.18 .. method:: select_item(index: int) -> None Selects the :obj:`~gi.repository.WebKit.OptionMenuItem` 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 :func:`~gi.repository.WebKit.OptionMenu.select_item` or close the menu with :func:`~gi.repository.WebKit.OptionMenu.close` in which case the currently selected item will be activated. .. versionadded:: 2.18 :param index: the index of the item Signals ------- .. rst-class:: interim-class .. class:: OptionMenu.signals :no-index: .. method:: close() -> None Emitted when closing a :obj:`~gi.repository.WebKit.OptionMenu` is requested. This can happen when the user explicitly calls :func:`~gi.repository.WebKit.OptionMenu.close` or when the element is detached from the current page. .. versionadded:: 2.18