Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can not get rid of Shift-Key in NSMenuItem Modifier Mask

I have a NSMenuItem that has a keyboard shortcut. I set the shortcut like this:

        // Close
    let closeItem = NSMenuItem()
    closeItem.title = Resources.QUIT
    closeItem.action = #selector(quit)
    closeItem.keyEquivalentModifierMask = [NSCommandKeyMask]
    closeItem.keyEquivalent = "Q"
    self.menu.addItem(closeItem)

Unfortunately, I can not get rid of the "Shift" key:

Result

What is the problem with my code?

like image 278
inexcitus Avatar asked Mar 10 '23 10:03

inexcitus


1 Answers

The solution was pretty easy: Instead of using "Q", I used "q" and the shift modifier was gone. The new code:

self.menu.addItem(NSMenuItem(title: Resources.QUIT, action: #selector(quit), keyEquivalent: "q"))
like image 198
inexcitus Avatar answered Mar 29 '23 20:03

inexcitus