Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Macos: Cmd+Q, can not quit app #1416

Closed
daodao97 opened this issue May 22, 2022 · 7 comments
Closed

Macos: Cmd+Q, can not quit app #1416

daodao97 opened this issue May 22, 2022 · 7 comments
Labels
Bug Something isn't working

Comments

@daodao97
Copy link
Contributor

Description

First, Thanks very much wails team,

I build my app with wails2, github url is EasyClash

When app is open, press Cmd + Q, can not quit app.

To Reproduce

  1. open EasyClash
  2. Press Cmd+Q

Expected behaviour

Quit App when press Cmd+Q

Screenshots

No response

Attempted Fixes

No response

System Details

Wails CLI v2.0.0-beta.36


Scanning system - Please wait (this may take a long time)...Done.

System
------
OS:		MacOS
Version: 	11.6
ID:		199506
Go Version:	go1.17.2
Platform:	darwin
Architecture:	amd64

Wails
------
Version: 	v2.0.0-beta.36

Dependency			Package Name	Status		Version
----------			------------	------		-------
xcode command line tools 	N/A		Installed	2384
npm 				N/A		Installed	8.0.0
*upx 				N/A		Installed	upx 3.96
*nsis 				N/A		Available

Additional context

No response

@daodao97 daodao97 added the Bug Something isn't working label May 22, 2022
@daodao97
Copy link
Contributor Author

Can reproduce in the template repo wails-vue3-tpl

@leaanthony
Copy link
Member

Did you bind it?

@daodao97
Copy link
Contributor Author

not did, if i write code like this, Cmd+Q can quit

    myMenu := menu.NewMenuFromItems(
        menu.SubMenu("File", menu.NewMenuFromItems(
            menu.Text("&Open", keys.CmdOrCtrl("o"), openFile),
            menu.Separator(),
            menu.Text("Quit", keys.CmdOrCtrl("q"), func(_ *menu.CallbackData) {
                runtime.Quit()
            }),
        )),
    )

    runtime.MenuSetApplicationMenu(myMenu)

but Cmd+C, Cmd+V will not working in app input html tag.

@leaanthony
Copy link
Member

leaanthony commented May 22, 2022

On Mac, you have to do that yourself, it's not a systemwide feature. There's an edit menu role that you can use.

@daodao97
Copy link
Contributor Author

in the source code pkg/options:Line 115

	switch runtime.GOOS {
	case "darwin":
		if appoptions.Menu == nil {
			appoptions.Menu = defaultMacMenu
		}
	}
var defaultMacMenu = menu.NewMenuFromItems(
	menu.AppMenu(),
	menu.EditMenu(),
)

if i set my custom enum, then must add menu.EditMenu() in my MenuFromItems, code example

	myMenu := menu.NewMenuFromItems(
		menu.SubMenu("File", menu.NewMenuFromItems(
			menu.Separator(),
			menu.Text("Quit", keys.CmdOrCtrl("q"), func(_ *menu.CallbackData) {
				runtime.Quit(context.Background())
			}),
		)),
		menu.EditMenu(),
	)

then, Cmd+A, Cmd+C, Cmd+V, Cmd+X is working.

maybe, we should tips it in docs.

@leaanthony
Copy link
Member

Happy to accept a PR!!!

@daodao97
Copy link
Contributor Author

PR @ pull/1423

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants