diff --git a/exp/examples/dialogs/main.go b/exp/examples/dialogs/main.go index 1820b75b9..0354fee7a 100644 --- a/exp/examples/dialogs/main.go +++ b/exp/examples/dialogs/main.go @@ -166,7 +166,7 @@ func main() { CanChooseFiles(true). CanCreateDirectories(true). ShowHiddenFiles(true). - AttachToWindow(app.GetCurrentWindow()). + AttachToWindow(app.CurrentWindow()). PromptForSingleSelection() if result != "" { app.NewInfoDialog().SetMessage(result).Show() @@ -277,7 +277,7 @@ func main() { }) saveMenu.Add("Select File (Attach To Window)").OnClick(func(ctx *application.Context) { result, _ := app.NewSaveFileDialog(). - AttachToWindow(app.GetCurrentWindow()). + AttachToWindow(app.CurrentWindow()). PromptForSingleSelection() if result != "" { app.NewInfoDialog().SetMessage(result).Show() diff --git a/exp/examples/menu/main.go b/exp/examples/menu/main.go index 3f12f3962..6f3581113 100644 --- a/exp/examples/menu/main.go +++ b/exp/examples/menu/main.go @@ -30,11 +30,11 @@ func main() { // You can control the current window from the menu myMenu.Add("Lock Window Resize").OnClick(func(ctx *application.Context) { - if app.GetCurrentWindow().Resizable() { - app.GetCurrentWindow().SetResizable(false) + if app.CurrentWindow().Resizable() { + app.CurrentWindow().SetResizable(false) ctx.ClickedMenuItem().SetLabel("Unlock Window Resize") } else { - app.GetCurrentWindow().SetResizable(true) + app.CurrentWindow().SetResizable(true) ctx.ClickedMenuItem().SetLabel("Lock Window Resize") } }) diff --git a/exp/pkg/application/application.go b/exp/pkg/application/application.go index 159c20423..039b6eba1 100644 --- a/exp/pkg/application/application.go +++ b/exp/pkg/application/application.go @@ -245,7 +245,7 @@ func (a *App) handleMenuItemClicked(menuItemID uint) { menuItem.handleClick() } -func (a *App) GetCurrentWindow() *Window { +func (a *App) CurrentWindow() *Window { if a.impl == nil { return nil } diff --git a/exp/pkg/application/menuitem_darwin.go b/exp/pkg/application/menuitem_darwin.go index 0ec8e45d3..f26e374d5 100644 --- a/exp/pkg/application/menuitem_darwin.go +++ b/exp/pkg/application/menuitem_darwin.go @@ -509,7 +509,7 @@ func newCloseMenuItem() *MenuItem { return newMenuItem("Close"). SetAccelerator("CmdOrCtrl+w"). OnClick(func(ctx *Context) { - currentWindow := globalApplication.GetCurrentWindow() + currentWindow := globalApplication.CurrentWindow() if currentWindow != nil { currentWindow.Close() } @@ -520,7 +520,7 @@ func newReloadMenuItem() *MenuItem { return newMenuItem("Reload"). SetAccelerator("CmdOrCtrl+r"). OnClick(func(ctx *Context) { - currentWindow := globalApplication.GetCurrentWindow() + currentWindow := globalApplication.CurrentWindow() if currentWindow != nil { currentWindow.Reload() } @@ -531,7 +531,7 @@ func newForceReloadMenuItem() *MenuItem { return newMenuItem("Force Reload"). SetAccelerator("CmdOrCtrl+Shift+r"). OnClick(func(ctx *Context) { - currentWindow := globalApplication.GetCurrentWindow() + currentWindow := globalApplication.CurrentWindow() if currentWindow != nil { currentWindow.ForceReload() } @@ -541,7 +541,7 @@ func newForceReloadMenuItem() *MenuItem { func newToggleFullscreenMenuItem() *MenuItem { result := newMenuItem("Toggle Full Screen"). OnClick(func(ctx *Context) { - currentWindow := globalApplication.GetCurrentWindow() + currentWindow := globalApplication.CurrentWindow() if currentWindow != nil { currentWindow.ToggleFullscreen() } @@ -558,7 +558,7 @@ func newToggleDevToolsMenuItem() *MenuItem { return newMenuItem("Toggle Developer Tools"). SetAccelerator("Alt+Command+I"). OnClick(func(ctx *Context) { - currentWindow := globalApplication.GetCurrentWindow() + currentWindow := globalApplication.CurrentWindow() if currentWindow != nil { currentWindow.ToggleDevTools() } @@ -570,7 +570,7 @@ func newResetZoomMenuItem() *MenuItem { return newMenuItem("Actual Size"). SetAccelerator("CmdOrCtrl+0"). OnClick(func(ctx *Context) { - currentWindow := globalApplication.GetCurrentWindow() + currentWindow := globalApplication.CurrentWindow() if currentWindow != nil { currentWindow.ResetZoom() } @@ -581,7 +581,7 @@ func newZoomInMenuItem() *MenuItem { return newMenuItem("Zoom In"). SetAccelerator("CmdOrCtrl+plus"). OnClick(func(ctx *Context) { - currentWindow := globalApplication.GetCurrentWindow() + currentWindow := globalApplication.CurrentWindow() if currentWindow != nil { currentWindow.ZoomIn() } @@ -592,7 +592,7 @@ func newZoomOutMenuItem() *MenuItem { return newMenuItem("Zoom Out"). SetAccelerator("CmdOrCtrl+-"). OnClick(func(ctx *Context) { - currentWindow := globalApplication.GetCurrentWindow() + currentWindow := globalApplication.CurrentWindow() if currentWindow != nil { currentWindow.ZoomOut() } @@ -603,7 +603,7 @@ func newMinimizeMenuItem() *MenuItem { return newMenuItem("Minimize"). SetAccelerator("CmdOrCtrl+M"). OnClick(func(ctx *Context) { - currentWindow := globalApplication.GetCurrentWindow() + currentWindow := globalApplication.CurrentWindow() if currentWindow != nil { currentWindow.Minimize() } @@ -613,7 +613,7 @@ func newMinimizeMenuItem() *MenuItem { func newZoomMenuItem() *MenuItem { return newMenuItem("Zoom"). OnClick(func(ctx *Context) { - currentWindow := globalApplication.GetCurrentWindow() + currentWindow := globalApplication.CurrentWindow() if currentWindow != nil { currentWindow.Zoom() } diff --git a/exp/pkg/application/roles.go b/exp/pkg/application/roles.go index 00f32148d..b6f2b2da9 100644 --- a/exp/pkg/application/roles.go +++ b/exp/pkg/application/roles.go @@ -140,7 +140,7 @@ func newWindowMenu() *MenuItem { func newHelpMenu() *MenuItem { menu := NewMenu() menu.Add("Learn More").OnClick(func(ctx *Context) { - globalApplication.GetCurrentWindow().NavigateToURL("https://wails.io") + globalApplication.CurrentWindow().NavigateToURL("https://wails.io") }) subMenu := newSubMenuItem("Help") subMenu.submenu = menu