Xojo Conferences
XDCMay2019MiamiUSA

[MBS] NSStatusItemMBS keyboard shortcut (MBS Xojo Plugin Mailinglist archive)

Back to the thread list
Previous thread: [MBS] CocoaControlMBS HasFocus?
Next thread: [MBS] Problem loading Phidgets framework in Windows


[MBS] Cocoa and MBS   -   Garth Hjelte
  [MBS] NSStatusItemMBS keyboard shortcut   -   Gavin Smith
   Re: [MBS] NSStatusItemMBS keyboard shortcut   -   Christian Schmitz
   Re: [MBS] NSStatusItemMBS keyboard shortcut   -   Gavin Smith
   Re: [MBS] NSStatusItemMBS keyboard shortcut   -   Christian Schmitz
   Re: [MBS] NSStatusItemMBS keyboard shortcut   -   Gavin Smith
   Re: [MBS] NSStatusItemMBS keyboard shortcut   -   Gavin Smith
   Re: [MBS] NSStatusItemMBS keyboard shortcut   -   Christian Schmitz

[MBS] NSStatusItemMBS keyboard shortcut
Date: 11.09.12 13:46 (Tue, 11 Sep 2012 13:46:01 +0100)
From: Gavin Smith
I am still evaluating the plugins, I will hopefully buy if I can get this and another issue resolved.

I am trying to implement keyboard shortcuts on NSStatusItems but I can't figure out how. The StatusItem example app has .keyequivalent set and you can see the shortcut in the menu but I'm not sure if this has been implemented - maybe it's just for an example?

I would appreciate any help in getting keyboard shortcuts working with NSStatusItems.

Gavin
_______________________________________________
Mbsplugins_monkeybreadsoftware.info mailing list
<email address removed>
https://ml01.ispgateway.de/mailman/listinfo/mbsplugins_monkeybreadsoftware.info

Re: [MBS] NSStatusItemMBS keyboard shortcut
Date: 13.09.12 20:57 (Thu, 13 Sep 2012 21:57:44 +0200)
From: Christian Schmitz

Am 13.09.2012 um 21:45 schrieb Gavin Smith <gavinsmith@me.com>:

> Actually, I was too hasty in dismissing this - CarbonHotKeyMBS looks to be exactly what I want. When compiled as Cocoa, do you know if it will pass the Mac App Store or is there something there that will cause an app to be rejected?
>
> I'd love an answer to this, thanks very much.

Carbon Events are the base of Cocoa events, so this is fine.

Greetings
Christian

Re: [MBS] NSStatusItemMBS keyboard shortcut
Date: 13.09.12 20:45 (Thu, 13 Sep 2012 20:45:59 +0100)
From: Gavin Smith
On Sep 11, 2012, at 4:21 PM, Christian Schmitz <<email address removed>> wrote:

>
> Am 11.09.2012 um 16:50 schrieb Gavin Smith <gavinsmith@me.com>:
>
>> Doesn't work for me on 10.8.1, latest plugins, latest RS on MBA 11" 2012. I've tried pressing the Fn key at the same time, but I just get the Mac error sound. I can select the menu item as normal with the mouse.
>
> Well, the one thing is showing the right shortcut.
>
> The other thing is watch globally for the shortcut. And the Carbon Events Hotkey Test example works fine when compiled as Cocoa.

Actually, I was too hasty in dismissing this - CarbonHotKeyMBS looks to be exactly what I want. When compiled as Cocoa, do you know if it will pass the Mac App Store or is there something there that will cause an app to be rejected?

I'd love an answer to this, thanks very much.
Gavin
_______________________________________________
Mbsplugins_monkeybreadsoftware.info mailing list
<email address removed>
https://ml01.ispgateway.de/mailman/listinfo/mbsplugins_monkeybreadsoftware.info

Re: [MBS] NSStatusItemMBS keyboard shortcut
Date: 11.09.12 16:21 (Tue, 11 Sep 2012 17:21:20 +0200)
From: Christian Schmitz

Am 11.09.2012 um 16:50 schrieb Gavin Smith <gavinsmith@me.com>:

> Doesn't work for me on 10.8.1, latest plugins, latest RS on MBA 11" 2012. I've tried pressing the Fn key at the same time, but I just get the Mac error sound. I can select the menu item as normal with the mouse.

Well, the one thing is showing the right shortcut.

The other thing is watch globally for the shortcut. And the Carbon Events Hotkey Test example works fine when compiled as Cocoa.

Greetings
Christian

Re: [MBS] NSStatusItemMBS keyboard shortcut
Date: 11.09.12 15:50 (Tue, 11 Sep 2012 15:50:44 +0100)
From: Gavin Smith

On Sep 11, 2012, at 3:27 PM, Christian Schmitz <<email address removed>> wrote:

>
> Am 11.09.2012 um 14:46 schrieb Gavin Smith <gavinsmith@me.com>:
>
>> I am trying to implement keyboard shortcuts on NSStatusItems but I can't figure out how. The StatusItem example app has .keyequivalent set and you can see the shortcut in the menu but I'm not sure if this has been implemented - maybe it's just for an example?
>>
>> I would appreciate any help in getting keyboard shortcuts working with NSStatusItems.
>
> You can try like this:
>
> a.keyEquivalent = encodings.UTF8.Chr(NSEventMBS.NSF6FunctionKey)
> a.keyEquivalentModifierMask = NSEventMBS.NSCommandKeyMask
>
> this works for me and shows command F6 in the menu and menu item action is executed when the app is frontmost.

Doesn't work for me on 10.8.1, latest plugins, latest RS on MBA 11" 2012. I've tried pressing the Fn key at the same time, but I just get the Mac error sound. I can select the menu item as normal with the mouse.
_______________________________________________
Mbsplugins_monkeybreadsoftware.info mailing list
<email address removed>
https://ml01.ispgateway.de/mailman/listinfo/mbsplugins_monkeybreadsoftware.info

Re: [MBS] NSStatusItemMBS keyboard shortcut
Date: 11.09.12 15:46 (Tue, 11 Sep 2012 15:46:11 +0100)
From: Gavin Smith

On Sep 11, 2012, at 3:27 PM, Christian Schmitz <<email address removed>> wrote:

>
> Am 11.09.2012 um 14:46 schrieb Gavin Smith <gavinsmith@me.com>:
>
>> I am trying to implement keyboard shortcuts on NSStatusItems but I can't figure out how. The StatusItem example app has .keyequivalent set and you can see the shortcut in the menu but I'm not sure if this has been implemented - maybe it's just for an example?
>>
>> I would appreciate any help in getting keyboard shortcuts working with NSStatusItems.
>
> You can try like this:
>
> a.keyEquivalent = encodings.UTF8.Chr(NSEventMBS.NSF6FunctionKey)
> a.keyEquivalentModifierMask = NSEventMBS.NSCommandKeyMask
>
> this works for me and shows command F6 in the menu and menu item action is executed when the app is frontmost.
>
> For background, you'd need something like CarbonHotKeyMBS class.

Yes, I have been researching further since I posted - I thought an NSStatusItem keyboard shortcut would have done, even if the app was background but of course it doesn't. Would CarbonHotKeyMBS still be allowable on the Mac App Store? I was hoping for a nice Cocoa solution, such as http://blog.shpakovski.com/2012/07/global-keyboard-shortcuts-in-cocoa.html

Gavin
_______________________________________________
Mbsplugins_monkeybreadsoftware.info mailing list
<email address removed>
https://ml01.ispgateway.de/mailman/listinfo/mbsplugins_monkeybreadsoftware.info

Re: [MBS] NSStatusItemMBS keyboard shortcut
Date: 11.09.12 15:27 (Tue, 11 Sep 2012 16:27:18 +0200)
From: Christian Schmitz

Am 11.09.2012 um 14:46 schrieb Gavin Smith <gavinsmith@me.com>:

> I am trying to implement keyboard shortcuts on NSStatusItems but I can't figure out how. The StatusItem example app has .keyequivalent set and you can see the shortcut in the menu but I'm not sure if this has been implemented - maybe it's just for an example?
>
> I would appreciate any help in getting keyboard shortcuts working with NSStatusItems.

You can try like this:

a.keyEquivalent = encodings.UTF8.Chr(NSEventMBS.NSF6FunctionKey)
a.keyEquivalentModifierMask = NSEventMBS.NSCommandKeyMask

this works for me and shows command F6 in the menu and menu item action is executed when the app is frontmost.

For background, you'd need something like CarbonHotKeyMBS class.

Greetings
Christian