OptionMenu

Added in version 2.18.

class OptionMenu(**properties: Any)

Superclasses: Object

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

When a select element in a WebView needs to display a dropdown menu, the signal WebView::show-option-menu is emitted, providing a WebKitOptionMenu with the :obj:`~gi.repository.WebKit.OptionMenuItem`<!– –>s that should be displayed.

Methods

class OptionMenu
activate_item(index: int) None

Activates the 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 close() after activating an item, calling this function again will have no effect.

Added in version 2.18.

Parameters:

index – the index of the item

close() None

Request to close a 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 select_item() nor activate_item() have been called, the element value remains unchanged.

Added in version 2.18.

get_event() Event

Gets the Event that triggered the dropdown menu. If menu was not triggered by a user interaction, like a mouse click, None is returned.

Added in version 2.40.

get_item(index: int) OptionMenuItem

Returns the OptionMenuItem at index in menu.

Added in version 2.18.

Parameters:

index – the index of the item

get_n_items() int

Gets the length of the menu.

Added in version 2.18.

select_item(index: int) None

Selects the 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 select_item() or close the menu with close() in which case the currently selected item will be activated.

Added in version 2.18.

Parameters:

index – the index of the item

Signals

class OptionMenu.signals
close() None

Emitted when closing a OptionMenu is requested. This can happen when the user explicitly calls close() or when the element is detached from the current page.

Added in version 2.18.