mirror of
https://github.com/wailsapp/wails.git
synced 2026-03-14 14:45:49 +01:00
[v3 linux] contextMenus
This commit is contained in:
parent
e420900e55
commit
0fc535f2f1
2 changed files with 28 additions and 14 deletions
|
|
@ -233,6 +233,23 @@ func appDestroy(application pointer) {
|
|||
C.g_application_quit((*C.GApplication)(application))
|
||||
}
|
||||
|
||||
func contextMenuShow(window pointer, menu pointer, data *ContextMenuData) {
|
||||
geometry := C.GdkRectangle{
|
||||
x: C.int(data.X),
|
||||
y: C.int(data.Y),
|
||||
}
|
||||
event := C.GdkEvent{}
|
||||
gdkWindow := C.gtk_widget_get_window((*C.GtkWidget)(window))
|
||||
C.gtk_menu_popup_at_rect(
|
||||
(*C.GtkMenu)(menu),
|
||||
gdkWindow,
|
||||
(*C.GdkRectangle)(&geometry),
|
||||
C.GDK_GRAVITY_NORTH_WEST,
|
||||
C.GDK_GRAVITY_NORTH_WEST,
|
||||
(*C.GdkEvent)(&event),
|
||||
)
|
||||
}
|
||||
|
||||
func getCurrentWindowID(application pointer, windows map[windowPointer]uint) uint {
|
||||
// TODO: Add extra metadata to window and use it!
|
||||
window := (*C.GtkWindow)(C.gtk_application_get_active_window((*C.GtkApplication)(application)))
|
||||
|
|
|
|||
|
|
@ -57,20 +57,17 @@ func (w *linuxWebviewWindow) connectSignals() {
|
|||
}
|
||||
|
||||
func (w *linuxWebviewWindow) openContextMenu(menu *Menu, data *ContextMenuData) {
|
||||
// Create the menu
|
||||
thisMenu := newMenuImpl(menu)
|
||||
thisMenu.update()
|
||||
fmt.Println("linux.openContextMenu() - not implemented")
|
||||
/* void
|
||||
gtk_menu_popup_at_rect (
|
||||
GtkMenu* menu,
|
||||
GdkWindow* rect_window,
|
||||
const GdkRectangle* rect,
|
||||
GdkGravity rect_anchor,
|
||||
GdkGravity menu_anchor,
|
||||
const GdkEvent* trigger_event
|
||||
)
|
||||
*/
|
||||
// Create the menu manually because we don't want a gtk_menu_bar
|
||||
// as the top-level item
|
||||
ctxMenu := &linuxMenu{
|
||||
menu: menu,
|
||||
}
|
||||
if menu.impl == nil {
|
||||
ctxMenu.update()
|
||||
}
|
||||
|
||||
native := ctxMenu.menu.impl.(*linuxMenu).native
|
||||
contextMenuShow(w.window, native, data)
|
||||
}
|
||||
|
||||
func (w *linuxWebviewWindow) getZoom() float64 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue