Revert "Remove OpenContextMenu" (#3524)

This reverts commit 54140e9adb.
This commit is contained in:
Atterpac 2024-06-01 14:30:17 -06:00 committed by GitHub
commit 0dd73e249d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 20 additions and 0 deletions

View file

@ -1094,6 +1094,25 @@ func (w *WebviewWindow) HandleDragAndDropMessage(filenames []string) {
}
}
func (w *WebviewWindow) OpenContextMenu(data *ContextMenuData) {
menu, ok := w.contextMenus[data.Id]
if !ok {
// try application level context menu
menu, ok = globalApplication.getContextMenu(data.Id)
if !ok {
w.Error("No context menu found for id: %s", data.Id)
return
}
}
menu.setContextData(data)
if w.impl == nil && !w.isDestroyed() {
return
}
InvokeSync(func() {
w.impl.openContextMenu(menu, data)
})
}
// RegisterContextMenu registers a context menu and assigns it the given name.
func (w *WebviewWindow) RegisterContextMenu(name string, menu *Menu) {
w.contextMenusLock.Lock()

View file

@ -44,6 +44,7 @@ type Window interface {
Minimise() Window
Name() string
On(eventType events.WindowEventType, callback func(event *WindowEvent)) func()
OpenContextMenu(data *ContextMenuData)
RegisterContextMenu(name string, menu *Menu)
RelativePosition() (int, int)
Reload()