Package org.gnome.webkit
Interface WebView.ContextMenuCallback
- All Superinterfaces:
FunctionPointer
- Enclosing class:
WebView
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Functional interface declaration of the
ContextMenuCallback
callback.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionboolean
run
(ContextMenu contextMenu, HitTestResult hitTestResult) Emitted when a context menu is about to be displayed to give the application a chance to customize the proposed menu, prevent the menu from being displayed, or build its own context menu.default MemorySegment
toCallback
(Arena arena) Creates a native function pointer to theupcall(java.lang.foreign.MemorySegment, java.lang.foreign.MemorySegment, java.lang.foreign.MemorySegment)
method.default int
upcall
(MemorySegment sourceWebView, MemorySegment contextMenu, MemorySegment hitTestResult) Theupcall
method is called from native code.
-
Method Details
-
run
Emitted when a context menu is about to be displayed to give the application a chance to customize the proposed menu, prevent the menu from being displayed, or build its own context menu. <itemizedlist> <listitem><para> To customize the proposed menu you can use webkit_context_menu_prepend(), webkit_context_menu_append() or webkit_context_menu_insert() to add newWebKitContextMenuItem
<!-- -->s tocontextMenu
, webkit_context_menu_move_item() to reorder existing items, or webkit_context_menu_remove() to remove an existing item. The signal handler should returnfalse
, and the menu represented bycontextMenu
will be shown. </para></listitem> <listitem><para> To prevent the menu from being displayed you can just connect to this signal and returntrue
so that the proposed menu will not be shown. </para></listitem> <listitem><para> To build your own menu, you can remove all items from the proposed menu with webkit_context_menu_remove_all(), add your own items and returnfalse
so that the menu will be shown. You can also ignore the proposedWebKitContextMenu
, build your ownGtkMenu
and returntrue
to prevent the proposed menu from being shown. </para></listitem> <listitem><para> If you just want the default menu to be shown always, simply don't connect to this signal because showing the proposed context menu is the default behaviour. </para></listitem> </itemizedlist>If the signal handler returns
false
the context menu represented bycontextMenu
will be shown, if it returntrue
the context menu will not be shown.The proposed
WebKitContextMenu
passed incontextMenu
argument is only valid during the signal emission. -
upcall
default int upcall(MemorySegment sourceWebView, MemorySegment contextMenu, MemorySegment hitTestResult) Theupcall
method is called from native code. The parameters are marshaled andrun(org.gnome.webkit.ContextMenu, org.gnome.webkit.HitTestResult)
is executed. -
toCallback
Creates a native function pointer to theupcall(java.lang.foreign.MemorySegment, java.lang.foreign.MemorySegment, java.lang.foreign.MemorySegment)
method.- Specified by:
toCallback
in interfaceFunctionPointer
- Parameters:
arena
- the function pointer will be allocated in this arena- Returns:
- the native function pointer
-