Class ContextMenu
- All Implemented Interfaces:
Proxy
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 WebKitWebView
::context-menu signal, which has the
WebKitContextMenu
as an argument. You can modify it, adding new
submenus that you can create with webkit_context_menu_new(), adding
new WebKitContextMenuItem
<!-- -->s with
webkit_context_menu_prepend(), webkit_context_menu_append() or
webkit_context_menu_insert(), maybe after having removed the
existing ones with webkit_context_menu_remove_all().
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
ContextMenu.Builder<B extends ContextMenu.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.static class
Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass
-
Constructor Summary
ConstructorDescriptionCreates a newWebKitContextMenu
object.ContextMenu
(MemorySegment address) Create a ContextMenu proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionvoid
append
(ContextMenuItem item) Addsitem
at the end of the this ContextMenu.protected ContextMenu
asParent()
Returns this instance as if it were its parent type.static ContextMenu.Builder
<? extends ContextMenu.Builder> builder()
AContextMenu.Builder
object constructs aContextMenu
with the specified properties.first()
Gets the first item in the this ContextMenu.getEvent()
Gets theGdkEvent
that triggered the context menu.getItemAtPosition
(int position) Gets the item at the given position in the this ContextMenu.getItems()
Returns the item list of this ContextMenu.int
Gets the length of the this ContextMenu.static Type
getType()
Get the GType of the ContextMenu classGets the user data of this ContextMenu.void
insert
(ContextMenuItem item, int position) Insertsitem
into the this ContextMenu at the given position.last()
Gets the last item in the this ContextMenu.void
moveItem
(ContextMenuItem item, int position) Movesitem
to the given position in the this ContextMenu.void
prepend
(ContextMenuItem item) Addsitem
at the beginning of the this ContextMenu.void
remove
(ContextMenuItem item) Removesitem
from the this ContextMenu.void
Removes all items of the this ContextMenu.void
setUserData
(Variant userData) Sets user data to this ContextMenu.static ContextMenu
withItems
(List<ContextMenuItem> items) Creates a newWebKitContextMenu
object with the given items.Methods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getMemoryLayout, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newInstance, newInstance, newv, notify_, notify_, notifyByPspec, onNotify, ref, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref, withProperties
Methods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, getPrivate, readGClass, writeGClass
Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
ContextMenu
Create a ContextMenu proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
ContextMenu
Creates a newWebKitContextMenu
object.Creates a new
WebKitContextMenu
object to be used as a submenu of an existingWebKitContextMenu
. The context menu of aWebKitWebView
is created by the view and passed as an argument ofWebKitWebView
::context-menu signal. To add items to the menu use webkit_context_menu_prepend(), webkit_context_menu_append() or webkit_context_menu_insert(). See also webkit_context_menu_new_with_items() to create aWebKitContextMenu
with a list of initial items.- Throws:
UnsupportedPlatformException
- when run on a platform other than linux
-
-
Method Details
-
getType
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuper
keyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()
doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName()
. This will call the native function pointer of this virtual method in the typeclass of the parent type. -
withItems
Creates a newWebKitContextMenu
object with the given items.Creates a new
WebKitContextMenu
object to be used as a submenu of an existingWebKitContextMenu
with the given initial items. See also webkit_context_menu_new()- Parameters:
items
- aGList
ofWebKitContextMenuItem
- Returns:
- The newly created
WebKitContextMenu
object - Throws:
UnsupportedPlatformException
- when run on a platform other than linux
-
append
Addsitem
at the end of the this ContextMenu.- Parameters:
item
- theWebKitContextMenuItem
to add
-
first
Gets the first item in the this ContextMenu.- Returns:
- the first
WebKitContextMenuItem
of this ContextMenu, ornull
if theWebKitContextMenu
is empty.
-
getEvent
Gets theGdkEvent
that triggered the context menu. This function only returns a validGdkEvent
when called for aWebKitContextMenu
passed toWebKitWebView
::context-menu signal; in all other cases,null
is returned.The returned
GdkEvent
is expected to be one of the following types: <itemizedlist> <listitem><para> aGdkEventButton
of typeEventType.BUTTON_PRESS
when the context menu was triggered with mouse. </para></listitem> <listitem><para> aGdkEventKey
of typeEventType.KEY_PRESS
if the keyboard was used to show the menu. </para></listitem> <listitem><para> a genericGdkEvent
of typeGDK_NOTHING
when theGtkWidget
::popup-menu signal was used to show the context menu. </para></listitem> </itemizedlist>- Returns:
- the menu event or
null
.
-
getItemAtPosition
Gets the item at the given position in the this ContextMenu.- Parameters:
position
- the position of the item, counting from 0- Returns:
- the
WebKitContextMenuItem
at positionposition
in this ContextMenu, ornull
if the position is off the end of the this ContextMenu.
-
getItems
Returns the item list of this ContextMenu.- Returns:
- a
GList
ofWebKitContextMenuItem
<!-- -->s
-
getNItems
public int getNItems()Gets the length of the this ContextMenu.- Returns:
- the number of
WebKitContextMenuItem
<!-- -->s in this ContextMenu
-
getUserData
Gets the user data of this ContextMenu.This function can be used from the UI Process to get user data previously set from the Web Process with webkit_context_menu_set_user_data().
- Returns:
- the user data of this ContextMenu, or
null
if this ContextMenu doesn't have user data
-
insert
Insertsitem
into the this ContextMenu at the given position.If
position
is negative, or is larger than the number of items in theWebKitContextMenu
, the item is added on to the end of the this ContextMenu. The first position is 0.- Parameters:
item
- theWebKitContextMenuItem
to addposition
- the position to insert the item
-
last
Gets the last item in the this ContextMenu.- Returns:
- the last
WebKitContextMenuItem
of this ContextMenu, ornull
if theWebKitContextMenu
is empty.
-
moveItem
Movesitem
to the given position in the this ContextMenu.If
position
is negative, or is larger than the number of items in theWebKitContextMenu
, the item is added on to the end of the this ContextMenu. The first position is 0.- Parameters:
item
- theWebKitContextMenuItem
to addposition
- the new position to move the item
-
prepend
Addsitem
at the beginning of the this ContextMenu.- Parameters:
item
- theWebKitContextMenuItem
to add
-
remove
Removesitem
from the this ContextMenu.See also webkit_context_menu_remove_all() to remove all items.
- Parameters:
item
- theWebKitContextMenuItem
to remove
-
removeAll
public void removeAll()Removes all items of the this ContextMenu. -
setUserData
Sets user data to this ContextMenu.This function can be used from a Web Process extension to set user data that can be retrieved from the UI Process using webkit_context_menu_get_user_data(). If the
userData
GVariant
is floating, it is consumed.- Parameters:
userData
- aGVariant
-
builder
AContextMenu.Builder
object constructs aContextMenu
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withContextMenu.Builder.build()
.
-