1.7 <WebKitContextMenu>

Class: <WebKitContextMenu>

It derives from <GObject>.

Represents the context menu in a <WebKitWebView>.

<WebKitContextMenu> represents a context menu containing <WebKitContextMenuItem><!– –>s in a <WebKitWebView>.

When a <WebKitWebView> is about to display the context menu, it emits the web-view:context-menu signal, which has the <WebKitContextMenu> as an argument. You can modify it, adding new submenus that you can create with context-menu:new, adding new <WebKitContextMenuItem><!– –>s with context-menu:prepend, context-menu:append or context-menu:insert, maybe after having removed the existing ones with context-menu:remove-all.

Procedures

Method: context-menu:append self item
Method: append self item

Adds item at the end of the self.

self

Passed: a <WebKitContextMenu>.

a <WebKitContextMenu>

item

Passed: a <WebKitContextMenuItem>.

the <WebKitContextMenuItem> to add

Method: context-menu:first self ⇒ %return
Method: first self ⇒ %return

Gets the first item in the self.

self

Passed: a <WebKitContextMenu>.

a <WebKitContextMenu>

%return

Returned: a <WebKitContextMenuItem>.

the first <WebKitContextMenuItem> of self, or #f if the <WebKitContextMenu> is empty.

Method: context-menu:get-event self ⇒ %return
Method: get-event self ⇒ %return

Gets the <GdkEvent> that triggered the context menu. This function only returns a valid <GdkEvent> when called for a <WebKitContextMenu> passed to web-view:context-menu signal; in all other cases, #f is returned.

The returned <GdkEvent> is expected to be one of the following types:

  • a GdkEventButton of type button-press when the context menu was triggered with mouse.
  • a GdkEventKey of type key-press if the keyboard was used to show the menu.
  • a generic <GdkEvent> of type GDK_NOTHING when the "popup-menu" signal was used to show the context menu.
self

Passed: a <WebKitContextMenu>.

a <WebKitContextMenu>

%return

Returned: a <GdkEvent>.

the menu event or #f.

Method: context-menu:get-item-at-position self position ⇒ %return
Method: get-item-at-position self position ⇒ %return

Gets the item at the given position in the self.

self

Passed: a <WebKitContextMenu>.

a <WebKitContextMenu>

position

Passed: an unsigned 32-bit integer.

the position of the item, counting from 0

%return

Returned: a <WebKitContextMenuItem>.

the <WebKitContextMenuItem> at position position in self, or #f if the position is off the end of the self.

Method: context-menu:get-items self ⇒ %return
Method: get-items self ⇒ %return

Returns the item list of self.

self

Passed: a <WebKitContextMenu>.

a <WebKitContextMenu>

%return

Returned: a list, each a <WebKitContextMenuItem>.

a GList of <WebKitContextMenuItem><!– –>s

Method: context-menu:get-n-items self ⇒ %return
Method: get-n-items self ⇒ %return

Gets the length of the self.

self

Passed: a <WebKitContextMenu>.

a <WebKitContextMenu>

%return

Returned: an unsigned 32-bit integer.

the number of <WebKitContextMenuItem><!– –>s in self

Method: context-menu:get-position self ⇒ %return x y
Method: get-position self ⇒ %return x y

Gets the position in view coordinates where the context menu was triggered.

This function only returns valid coordinates when called for a <WebKitContextMenu> passed to web-view:context-menu signal.

self

Passed: a <WebKitContextMenu>.

a <WebKitContextMenu>

%return

Returned: a boolean.

#t if valid position coordinates are available, #f otherwise

x

Returned: a 32-bit integer.

return location for the x coordinate

y

Returned: a 32-bit integer.

return location for the y coordinate

Method: context-menu:get-user-data self ⇒ %return
Method: get-user-data self ⇒ %return

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 context-menu:set-user-data.

self

Passed: a <WebKitContextMenu>.

a <WebKitContextMenu>

%return

Returned: a <GVariant>.

the user data of self, or #f if self doesn’t have user data

Method: context-menu:insert self item position
Method: insert self item position

Inserts item into the self at the given position.

If position is negative, or is larger than the number of items in the <WebKitContextMenu>, the item is added on to the end of the self. The first position is 0.

self

Passed: a <WebKitContextMenu>.

a <WebKitContextMenu>

item

Passed: a <WebKitContextMenuItem>.

the <WebKitContextMenuItem> to add

position

Passed: a 32-bit integer.

the position to insert the item

Method: context-menu:last self ⇒ %return
Method: last self ⇒ %return

Gets the last item in the self.

self

Passed: a <WebKitContextMenu>.

a <WebKitContextMenu>

%return

Returned: a <WebKitContextMenuItem>.

the last <WebKitContextMenuItem> of self, or #f if the <WebKitContextMenu> is empty.

Method: context-menu:move-item self item position
Method: move-item self item position

Moves item to the given position in the self.

If position is negative, or is larger than the number of items in the <WebKitContextMenu>, the item is added on to the end of the self. The first position is 0.

self

Passed: a <WebKitContextMenu>.

a <WebKitContextMenu>

item

Passed: a <WebKitContextMenuItem>.

the <WebKitContextMenuItem> to add

position

Passed: a 32-bit integer.

the new position to move the item

Procedure: context-menu:new ⇒ %return

Creates a new <WebKitContextMenu> object.

Creates a new <WebKitContextMenu> object to be used as a submenu of an existing <WebKitContextMenu>. The context menu of a <WebKitWebView> is created by the view and passed as an argument of web-view:context-menu signal. To add items to the menu use context-menu:prepend, context-menu:append or context-menu:insert. See also context-menu:new-with-items to create a <WebKitContextMenu> with a list of initial items.

%return

Returned: a <WebKitContextMenu>.

The newly created <WebKitContextMenu> object

Procedure: context-menu:new-with-items items ⇒ %return

Creates a new <WebKitContextMenu> object with the given items.

Creates a new <WebKitContextMenu> object to be used as a submenu of an existing <WebKitContextMenu> with the given initial items. See also context-menu:new

items

Passed: a list, each a <WebKitContextMenuItem>.

a GList of <WebKitContextMenuItem>

%return

Returned: a <WebKitContextMenu>.

The newly created <WebKitContextMenu> object

Method: context-menu:prepend self item
Method: prepend self item

Adds item at the beginning of the self.

self

Passed: a <WebKitContextMenu>.

a <WebKitContextMenu>

item

Passed: a <WebKitContextMenuItem>.

the <WebKitContextMenuItem> to add

Method: context-menu:remove self item
Method: remove self item

Removes item from the self.

See also context-menu:remove-all to remove all items.

self

Passed: a <WebKitContextMenu>.

a <WebKitContextMenu>

item

Passed: a <WebKitContextMenuItem>.

the <WebKitContextMenuItem> to remove

Method: context-menu:remove-all self
Method: remove-all self

Removes all items of the self.

self

Passed: a <WebKitContextMenu>.

a <WebKitContextMenu>

Method: context-menu:set-user-data self user-data
Method: set-user-data self user-data

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 context-menu:get-user-data. If the user-data <GVariant> is floating, it is consumed.

self

Passed: a <WebKitContextMenu>.

a <WebKitContextMenu>

user-data

Passed: a <GVariant>.

a <GVariant>