mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-04 00:10:47 +08:00
Improved menus.
Fixed warning on windows quit.
This commit is contained in:
parent
56494d8d1a
commit
2c55110776
@ -36,6 +36,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Do not bind internal service methods in [#3720](https://github.com/wailsapp/wails/pull/3720) by [leaanthony](https://github.com/leaanthony)
|
||||
- [windows] Fixed system tray startup panic in [#3693](https://github.com/wailsapp/wails/issues/3693) by [@DeltaLaboratory](https://github.com/DeltaLaboratory)
|
||||
- Major menu item refactor and event handling. Mainly improves macOS for now. By [leaanthony](https://github.com/leaanthony)
|
||||
- [windows] Fixed `Failed to unregister class Chrome_WidgetWin_0` warning. By [leaanthony](https://github.com/leaanthony)
|
||||
|
||||
## v3.0.0-alpha.6 - 2024-07-30
|
||||
|
||||
|
@ -192,6 +192,8 @@ func (m *windowsApp) destroy() {
|
||||
return
|
||||
}
|
||||
globalApplication.cleanup()
|
||||
// Destroy the main thread window
|
||||
w32.DestroyWindow(m.mainThreadWindowHWND)
|
||||
// Post a quit message to the main thread
|
||||
w32.PostQuitMessage(0)
|
||||
}
|
||||
|
@ -1765,3 +1765,30 @@ func runSaveFileDialog(dialog *SaveFileDialogStruct) (chan string, error) {
|
||||
|
||||
return results, err
|
||||
}
|
||||
|
||||
func (w *linuxWebviewWindow) cut() {
|
||||
C.webkit_web_view_execute_editing_command(w.webview, C.WEBKIT_EDITING_COMMAND_CUT)
|
||||
}
|
||||
|
||||
func (w *linuxWebviewWindow) paste() {
|
||||
C.webkit_web_view_execute_editing_command(w.webview, C.WEBKIT_EDITING_COMMAND_PASTE)
|
||||
}
|
||||
|
||||
func (w *linuxWebviewWindow) copy() {
|
||||
C.webkit_web_view_execute_editing_command(w.webview, C.WEBKIT_EDITING_COMMAND_COPY)
|
||||
}
|
||||
|
||||
func (w *linuxWebviewWindow) selectAll() {
|
||||
C.webkit_web_view_execute_editing_command(w.webview, C.WEBKIT_EDITING_COMMAND_SELECT_ALL)
|
||||
}
|
||||
|
||||
func (w *linuxWebviewWindow) undo() {
|
||||
C.webkit_web_view_execute_editing_command(w.webview, C.WEBKIT_EDITING_COMMAND_UNDO)
|
||||
}
|
||||
|
||||
func (w *linuxWebviewWindow) redo() {
|
||||
C.webkit_web_view_execute_editing_command(w.webview, C.WEBKIT_EDITING_COMMAND_REDO)
|
||||
}
|
||||
|
||||
func (w *linuxWebviewWindow) delete() {
|
||||
}
|
||||
|
@ -44,7 +44,12 @@ func NewRedoMenuItem() *MenuItem {
|
||||
|
||||
func NewCutMenuItem() *MenuItem {
|
||||
return NewMenuItem("Cut").
|
||||
SetAccelerator("CmdOrCtrl+x")
|
||||
SetAccelerator("CmdOrCtrl+x").OnClick(func(ctx *Context) {
|
||||
currentWindow := globalApplication.CurrentWindow()
|
||||
if currentWindow != nil {
|
||||
currentWindow.cut()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func NewCopyMenuItem() *MenuItem {
|
||||
|
@ -134,128 +134,6 @@ func newMenuItemImpl(item *MenuItem, parentMenu w32.HMENU, ID int) *windowsMenuI
|
||||
return result
|
||||
}
|
||||
|
||||
//func newAboutMenuItem() *MenuItem {
|
||||
// return NewMenuItem("About " + globalApplication.options.Name).
|
||||
// OnClick(func(ctx *Context) {
|
||||
// globalApplication.ShowAboutDialog()
|
||||
// })
|
||||
//}
|
||||
//
|
||||
//func newCloseMenuItem() *MenuItem {
|
||||
// return NewMenuItem("Close").
|
||||
// SetAccelerator("CmdOrCtrl+w").
|
||||
// OnClick(func(ctx *Context) {
|
||||
// currentWindow := globalApplication.CurrentWindow()
|
||||
// if currentWindow != nil {
|
||||
// currentWindow.Close()
|
||||
// }
|
||||
// })
|
||||
//}
|
||||
//func newReloadMenuItem() *MenuItem {
|
||||
// return NewMenuItem("Reload").
|
||||
// SetAccelerator("CmdOrCtrl+r").
|
||||
// OnClick(func(ctx *Context) {
|
||||
// currentWindow := globalApplication.CurrentWindow()
|
||||
// if currentWindow != nil {
|
||||
// currentWindow.Reload()
|
||||
// }
|
||||
// })
|
||||
//}
|
||||
//
|
||||
//func newForceReloadMenuItem() *MenuItem {
|
||||
// return NewMenuItem("Force Reload").
|
||||
// SetAccelerator("CmdOrCtrl+Shift+r").
|
||||
// OnClick(func(ctx *Context) {
|
||||
// currentWindow := globalApplication.CurrentWindow()
|
||||
// if currentWindow != nil {
|
||||
// currentWindow.ForceReload()
|
||||
// }
|
||||
// })
|
||||
//}
|
||||
//
|
||||
//func newToggleFullscreenMenuItem() *MenuItem {
|
||||
// result := NewMenuItem("Toggle Full Screen").
|
||||
// OnClick(func(ctx *Context) {
|
||||
// currentWindow := globalApplication.CurrentWindow()
|
||||
// if currentWindow != nil {
|
||||
// currentWindow.ToggleFullscreen()
|
||||
// }
|
||||
// })
|
||||
// if runtime.GOOS == "darwin" {
|
||||
// result.SetAccelerator("Ctrl+Command+F")
|
||||
// } else {
|
||||
// result.SetAccelerator("F11")
|
||||
// }
|
||||
// return result
|
||||
//}
|
||||
//
|
||||
//func newZoomResetMenuItem() *MenuItem {
|
||||
// // reset zoom menu item
|
||||
// return NewMenuItem("Actual Size").
|
||||
// SetAccelerator("CmdOrCtrl+0").
|
||||
// OnClick(func(ctx *Context) {
|
||||
// currentWindow := globalApplication.CurrentWindow()
|
||||
// if currentWindow != nil {
|
||||
// currentWindow.ZoomReset()
|
||||
// }
|
||||
// })
|
||||
//}
|
||||
//
|
||||
//func newZoomInMenuItem() *MenuItem {
|
||||
// return NewMenuItem("Zoom In").
|
||||
// SetAccelerator("CmdOrCtrl+plus").
|
||||
// OnClick(func(ctx *Context) {
|
||||
// currentWindow := globalApplication.CurrentWindow()
|
||||
// if currentWindow != nil {
|
||||
// currentWindow.ZoomIn()
|
||||
// }
|
||||
// })
|
||||
//}
|
||||
//
|
||||
//func newZoomOutMenuItem() *MenuItem {
|
||||
// return NewMenuItem("Zoom Out").
|
||||
// SetAccelerator("CmdOrCtrl+-").
|
||||
// OnClick(func(ctx *Context) {
|
||||
// currentWindow := globalApplication.CurrentWindow()
|
||||
// if currentWindow != nil {
|
||||
// currentWindow.ZoomOut()
|
||||
// }
|
||||
// })
|
||||
//}
|
||||
//
|
||||
//func newFullScreenMenuItem() *MenuItem {
|
||||
// return NewMenuItem("Fullscreen").
|
||||
// OnClick(func(ctx *Context) {
|
||||
// currentWindow := globalApplication.CurrentWindow()
|
||||
// if currentWindow != nil {
|
||||
// currentWindow.Fullscreen()
|
||||
// }
|
||||
// })
|
||||
//}
|
||||
//
|
||||
//func newMinimizeMenuItem() *MenuItem {
|
||||
// return NewMenuItem("Minimize").
|
||||
// SetAccelerator("CmdOrCtrl+M").
|
||||
// OnClick(func(ctx *Context) {
|
||||
// currentWindow := globalApplication.CurrentWindow()
|
||||
// if currentWindow != nil {
|
||||
// currentWindow.Minimise()
|
||||
// }
|
||||
// })
|
||||
//}
|
||||
//
|
||||
//func newZoomMenuItem() *MenuItem {
|
||||
// return NewMenuItem("Zoom").
|
||||
// OnClick(func(ctx *Context) {
|
||||
// currentWindow := globalApplication.CurrentWindow()
|
||||
// if currentWindow != nil {
|
||||
// currentWindow.Zoom()
|
||||
// }
|
||||
// })
|
||||
//}
|
||||
|
||||
// ---------- unsupported on windows ----------
|
||||
|
||||
func (m *windowsMenuItem) setTooltip(_ string) {
|
||||
// Unsupported
|
||||
}
|
||||
|
@ -92,6 +92,13 @@ type (
|
||||
setCloseButtonState(state ButtonState)
|
||||
isIgnoreMouseEvents() bool
|
||||
setIgnoreMouseEvents(ignore bool)
|
||||
cut()
|
||||
copy()
|
||||
paste()
|
||||
undo()
|
||||
delete()
|
||||
selectAll()
|
||||
redo()
|
||||
}
|
||||
)
|
||||
|
||||
@ -1265,3 +1272,39 @@ func (w *WebviewWindow) SetIgnoreMouseEvents(ignore bool) Window {
|
||||
})
|
||||
return w
|
||||
}
|
||||
|
||||
func (w *WebviewWindow) cut() {
|
||||
if w.impl == nil && !w.isDestroyed() {
|
||||
w.impl.cut()
|
||||
}
|
||||
}
|
||||
|
||||
func (w *WebviewWindow) copy() {
|
||||
if w.impl == nil && !w.isDestroyed() {
|
||||
w.impl.copy()
|
||||
}
|
||||
}
|
||||
|
||||
func (w *WebviewWindow) paste() {
|
||||
if w.impl == nil && !w.isDestroyed() {
|
||||
w.impl.paste()
|
||||
}
|
||||
}
|
||||
|
||||
func (w *WebviewWindow) selectAll() {
|
||||
if w.impl == nil && !w.isDestroyed() {
|
||||
w.impl.selectAll()
|
||||
}
|
||||
}
|
||||
|
||||
func (w *WebviewWindow) undo() {
|
||||
if w.impl == nil && !w.isDestroyed() {
|
||||
w.impl.undo()
|
||||
}
|
||||
}
|
||||
|
||||
func (w *WebviewWindow) delete() {
|
||||
if w.impl == nil && !w.isDestroyed() {
|
||||
w.impl.delete()
|
||||
}
|
||||
}
|
||||
|
@ -1348,3 +1348,24 @@ func (w *macosWebviewWindow) isIgnoreMouseEvents() bool {
|
||||
func (w *macosWebviewWindow) setIgnoreMouseEvents(ignore bool) {
|
||||
C.setIgnoreMouseEvents(w.nsWindow, C.bool(ignore))
|
||||
}
|
||||
|
||||
func (w *macosWebviewWindow) cut() {
|
||||
}
|
||||
|
||||
func (w *macosWebviewWindow) paste() {
|
||||
}
|
||||
|
||||
func (w *macosWebviewWindow) copy() {
|
||||
}
|
||||
|
||||
func (w *macosWebviewWindow) selectAll() {
|
||||
}
|
||||
|
||||
func (w *macosWebviewWindow) undo() {
|
||||
}
|
||||
|
||||
func (w *macosWebviewWindow) delete() {
|
||||
}
|
||||
|
||||
func (w *macosWebviewWindow) redo() {
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
package application
|
||||
|
||||
import (
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
|
@ -72,6 +72,33 @@ type windowsWebviewWindow struct {
|
||||
moveDebouncer func(func())
|
||||
}
|
||||
|
||||
func (w *windowsWebviewWindow) cut() {
|
||||
w32.Cut(w.hwnd)
|
||||
}
|
||||
|
||||
func (w *windowsWebviewWindow) paste() {
|
||||
w32.Paste(w.hwnd)
|
||||
}
|
||||
|
||||
func (w *windowsWebviewWindow) copy() {
|
||||
w32.Copy(w.hwnd)
|
||||
}
|
||||
|
||||
func (w *windowsWebviewWindow) selectAll() {
|
||||
w32.SelectAll(w.hwnd)
|
||||
}
|
||||
|
||||
func (w *windowsWebviewWindow) undo() {
|
||||
w32.Undo(w.hwnd)
|
||||
}
|
||||
|
||||
func (w *windowsWebviewWindow) delete() {
|
||||
w32.Delete(w.hwnd)
|
||||
}
|
||||
|
||||
func (w *windowsWebviewWindow) redo() {
|
||||
}
|
||||
|
||||
func (w *windowsWebviewWindow) handleKeyEvent(_ string) {
|
||||
// Unused on windows
|
||||
}
|
||||
@ -444,6 +471,8 @@ func (w *windowsWebviewWindow) destroy() {
|
||||
if w.dropTarget != nil {
|
||||
w.dropTarget.Release()
|
||||
}
|
||||
// Destroy the window
|
||||
w32.DestroyWindow(w.hwnd)
|
||||
}
|
||||
|
||||
func (w *windowsWebviewWindow) reload() {
|
||||
|
@ -1,3 +1,5 @@
|
||||
//go:build windows
|
||||
|
||||
package w32
|
||||
|
||||
func Undo(hwnd HWND) {
|
||||
|
Loading…
Reference in New Issue
Block a user