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
Nested ClassesModifier and TypeClassDescriptionstatic classContextMenu.Builder<B extends ContextMenu.Builder<B>>Inner class implementing a builder pattern to construct a GObject with properties.static classNested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new ContextMenu.ContextMenu(MemorySegment address) Create a ContextMenu proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionvoidappend(ContextMenuItem item) Addsitemat the end of themenu.protected ContextMenuasParent()Returns this instance as if it were its parent type.static ContextMenu.Builder<? extends ContextMenu.Builder> builder()AContextMenu.Builderobject constructs aContextMenuwith the specified properties.first()Gets the first item in themenu.getEvent()Gets theGdkEventthat triggered the context menu.getItemAtPosition(int position) Gets the item at the given position in themenu.getItems()Returns the item list ofmenu.intGets the length of themenu.static @Nullable TypegetType()Get the GType of the ContextMenu classGets the user data ofmenu.voidinsert(ContextMenuItem item, int position) Insertsiteminto the this ContextMenu at the given position.last()Gets the last item in themenu.voidmoveItem(ContextMenuItem item, int position) Movesitemto the given position in themenu.voidprepend(ContextMenuItem item) Addsitemat the beginning of themenu.voidremove(ContextMenuItem item) Removesitemfrom themenu.voidRemoves all items of themenu.voidsetUserData(Variant userData) Sets user data tomenu.static ContextMenuwithItems(List<ContextMenuItem> items) Creates a newWebKitContextMenuobject 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, 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, withPropertiesMethods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, cast, getPrivate, readGClass, writeGClassMethods inherited from class org.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
public ContextMenu()Creates a new ContextMenu.
-
-
Method Details
-
getType
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuperkeyword, 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 newWebKitContextMenuobject with the given items.Creates a new
WebKitContextMenuobject to be used as a submenu of an existingWebKitContextMenuwith the given initial items. See also webkit_context_menu_new()- Parameters:
items- aGListofWebKitContextMenuItem- Returns:
- The newly created
WebKitContextMenuobject
-
append
Addsitemat the end of themenu.- Parameters:
item- theWebKitContextMenuItemto add
-
first
Gets the first item in themenu.- Returns:
- the first
WebKitContextMenuItemofmenu,ornullif theWebKitContextMenuis empty.
-
getEvent
Gets theGdkEventthat triggered the context menu. This function only returns a validGdkEventwhen called for aWebKitContextMenupassed toWebKitWebView::context-menu signal; in all other cases,nullis returned.The returned
GdkEventis expected to be one of the following types: <itemizedlist> <listitem><para> aGdkEventButtonof typeEventType.BUTTON_PRESSwhen the context menu was triggered with mouse. </para></listitem> <listitem><para> aGdkEventKeyof typeEventType.KEY_PRESSif the keyboard was used to show the menu. </para></listitem> <listitem><para> a genericGdkEventof typeGDK_NOTHINGwhen theGtkWidget::popup-menu signal was used to show the context menu. </para></listitem> </itemizedlist>- Returns:
- the menu event or
null. - Since:
- 2.40
-
getItemAtPosition
Gets the item at the given position in themenu.- Parameters:
position- the position of the item, counting from 0- Returns:
- the
WebKitContextMenuItemat positionpositioninmenu,ornullif the position is off the end of themenu.
-
getItems
Returns the item list ofmenu.- Returns:
- a
GListofWebKitContextMenuItem<!-- -->s
-
getNItems
public int getNItems()Gets the length of themenu.- Returns:
- the number of
WebKitContextMenuItem<!-- -->s in this ContextMenu
-
getUserData
Gets the user data ofmenu.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
menu,ornullif this ContextMenu doesn't have user data - Since:
- 2.8
-
insert
Insertsiteminto the this ContextMenu at the given position.If
positionis negative, or is larger than the number of items in theWebKitContextMenu, the item is added on to the end of themenu.The first position is 0.- Parameters:
item- theWebKitContextMenuItemto addposition- the position to insert the item
-
last
Gets the last item in themenu.- Returns:
- the last
WebKitContextMenuItemofmenu,ornullif theWebKitContextMenuis empty.
-
moveItem
Movesitemto the given position in themenu.If
positionis negative, or is larger than the number of items in theWebKitContextMenu, the item is added on to the end of themenu.The first position is 0.- Parameters:
item- theWebKitContextMenuItemto addposition- the new position to move the item
-
prepend
Addsitemat the beginning of themenu.- Parameters:
item- theWebKitContextMenuItemto add
-
remove
Removesitemfrom themenu.See also webkit_context_menu_remove_all() to remove all items.
- Parameters:
item- theWebKitContextMenuItemto remove
-
removeAll
public void removeAll()Removes all items of themenu. -
setUserData
Sets user data tomenu.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
userDataGVariantis floating, it is consumed.- Parameters:
userData- aGVariant- Since:
- 2.8
-
builder
AContextMenu.Builderobject constructs aContextMenuwith the specified properties. Use the variousset...()methods to set properties, and finish construction withContextMenu.Builder.build().- Returns:
- the builder object
-