WebKit2.ContextMenu¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
None
Signals¶
- Inherited:
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
|---|---|---|---|
parent |
r |
Class Details¶
- class WebKit2.ContextMenu(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
Represents the context menu in a
WebKit2.WebView.WebKit2.ContextMenurepresents a context menu containingWebKit2.ContextMenuItems in aWebKit2.WebView.When a
WebKit2.WebViewis about to display the context menu, it emits theWebKit2.WebView::context-menusignal, which has theWebKit2.ContextMenuas an argument. You can modify it, adding new submenus that you can create withWebKit2.ContextMenu.new(), adding newWebKit2.ContextMenuItems withWebKit2.ContextMenu.prepend(),WebKit2.ContextMenu.append() orWebKit2.ContextMenu.insert(), maybe after having removed the existing ones withWebKit2.ContextMenu.remove_all().- classmethod new()¶
- Returns:
The newly created
WebKit2.ContextMenuobject- Return type:
Creates a new
WebKit2.ContextMenuobject.Creates a new
WebKit2.ContextMenuobject to be used as a submenu of an existingWebKit2.ContextMenu. The context menu of aWebKit2.WebViewis created by the view and passed as an argument ofWebKit2.WebView::context-menusignal. To add items to the menu useWebKit2.ContextMenu.prepend(),WebKit2.ContextMenu.append() orWebKit2.ContextMenu.insert(). See alsoWebKit2.ContextMenu.new_with_items() to create aWebKit2.ContextMenuwith a list of initial items.
- classmethod new_with_items(items)¶
- Parameters:
items ([
WebKit2.ContextMenuItem]) – aGLib.ListofWebKit2.ContextMenuItem- Returns:
The newly created
WebKit2.ContextMenuobject- Return type:
Creates a new
WebKit2.ContextMenuobject with the given items.Creates a new
WebKit2.ContextMenuobject to be used as a submenu of an existingWebKit2.ContextMenuwith the given initial items. See alsoWebKit2.ContextMenu.new()
- append(item)¶
- Parameters:
item (
WebKit2.ContextMenuItem) – theWebKit2.ContextMenuItemto add
Adds item at the end of the self.
- first()¶
- Returns:
the first
WebKit2.ContextMenuItemof self, orNoneif theWebKit2.ContextMenuis empty.- Return type:
Gets the first item in the self.
- get_event()¶
-
Gets the
Gdk.Eventthat triggered the context menu. This function only returns a validGdk.Eventwhen called for aWebKit2.ContextMenupassed toWebKit2.WebView::context-menusignal; in all other cases,Noneis returned.The returned
Gdk.Eventis expected to be one of the following types:a
Gdk.EventButtonof typeGdk.EventType.BUTTON_PRESSwhen the context menu was triggered with mouse.a
Gdk.EventKeyof typeGdk.EventType.KEY_PRESSif the keyboard was used to show the menu.a generic
Gdk.Eventof typeGdk.EventType.NOTHINGwhen theGtk.Widget::popup-menusignal was used to show the context menu.
New in version 2.40.
- get_item_at_position(position)¶
- Parameters:
position (
int) – the position of the item, counting from 0- Returns:
the
WebKit2.ContextMenuItemat position position in self, orNoneif the position is off the end of the self.- Return type:
Gets the item at the given position in the self.
- get_items()¶
- Returns:
a
GLib.ListofWebKit2.ContextMenuItems- Return type:
Returns the item list of self.
- get_n_items()¶
- Returns:
the number of
WebKit2.ContextMenuItems in self- Return type:
Gets the length of the self.
- get_user_data()¶
- Returns:
the user data of self, or
Noneif self doesn’t have user data- Return type:
Gets the user data of self.
This function can be used from the UI Process to get user data previously set from the Web Process with
WebKit2.ContextMenu.set_user_data().New in version 2.8.
- insert(item, position)¶
- Parameters:
item (
WebKit2.ContextMenuItem) – theWebKit2.ContextMenuItemto addposition (
int) – the position to insert the item
Inserts item into the self at the given position.
If position is negative, or is larger than the number of items in the
WebKit2.ContextMenu, the item is added on to the end of the self. The first position is 0.
- last()¶
- Returns:
the last
WebKit2.ContextMenuItemof self, orNoneif theWebKit2.ContextMenuis empty.- Return type:
Gets the last item in the self.
- move_item(item, position)¶
- Parameters:
item (
WebKit2.ContextMenuItem) – theWebKit2.ContextMenuItemto addposition (
int) – the new position to move the item
Moves item to the given position in the self.
If position is negative, or is larger than the number of items in the
WebKit2.ContextMenu, the item is added on to the end of the self. The first position is 0.
- prepend(item)¶
- Parameters:
item (
WebKit2.ContextMenuItem) – theWebKit2.ContextMenuItemto add
Adds item at the beginning of the self.
- remove(item)¶
- Parameters:
item (
WebKit2.ContextMenuItem) – theWebKit2.ContextMenuItemto remove
Removes item from the self.
See also
WebKit2.ContextMenu.remove_all() to remove all items.
- remove_all()¶
Removes all items of the self.
- set_user_data(user_data)¶
- Parameters:
user_data (
GLib.Variant) – aGLib.Variant
Sets user data to self.
This function can be used from a Web Process extension to set user data that can be retrieved from the UI Process using
WebKit2.ContextMenu.get_user_data(). If the user_dataGLib.Variantis floating, it is consumed.New in version 2.8.