Skip to content

Commit

Permalink
Revert "Remove OpenContextMenu" (#3524)
Browse files Browse the repository at this point in the history
This reverts commit 54140e9.
  • Loading branch information
atterpac authored Jun 1, 2024
1 parent 54140e9 commit 0dd73e2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
19 changes: 19 additions & 0 deletions v3/pkg/application/webview_window.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions v3/pkg/application/window.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 0dd73e2

Please sign in to comment.