Re: Give a menu keyboard focus – in code

2011-10-10 Thread Lee Ann Rucker
An issue I discovered recently: If your NSStatusItem uses a menu it gets 
AXPress for free but if it uses a custom view, the view needs to implement all 
the necessary accessibility pieces required for AXPress itself.

Granted its accessibility is rather lacking if keyboard navigation doesn't 
work, but at least it'll be there for other cases.

On Oct 10, 2011, at 10:23 AM, Charles Srstka wrote:

> On Oct 10, 2011, at 7:34 AM, Jerry Krinock wrote:
> 
>> 
>> On 2011 Oct 10, at 02:03, Martin Hewitson wrote:
>> 
>>> I haven't been following this thread closely, so I may be talking about the 
>>> wrong thing here, but I just noticed I can cycle through the status items, 
>>> and some of them (e.g. istat menus and apple items) are selectable with 
>>> ctrl-f8 then arrow keys, and some not (e.g. dropbox). So it seems like it's 
>>> possible, in principle. Don't know if that helps.
>> 
>> Thank you, Martin.  I have 7 non-Apple Status Items on my Mac account, and 
>> none of them are accessible via the F8 key.  However, you are correct.  I 
>> just installed iStat Menus from bjango.com and, indeed, its Status Items 
>> *are* accessible via F8.  Furthermore, instead of being appended to the 
>> left, they take priority over all the other non-Apple Status Items.  The 
>> right half of my menu bar looks like this:
>> 
>>   |  Other Non-Apple Items  |  iStat Menu Items  |  Apple Items 
>> 
>> Apparently, bjango has figured out a trick that no one else has.  I wonder 
>> if it's "legal”?
> 
> It looks like they’re just using the private NSMenuExtra API. They’re 
> probably using code injection to patch SystemUIServer to get around Apple’s 
> protection to do so.
> 
> Not something I’d recommend.
> 
> Charles___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/lrucker%40vmware.com
> 
> This email sent to lruc...@vmware.com

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Give a menu keyboard focus – in code

2011-10-10 Thread Andy Lee
Sounds great, Jerry. Thanks for sharing the details of your approach.

--Andy

On Oct 10, 2011, at 2:10 PM, Jerry Krinock wrote:

> 
> On 2011 Oct 10, at 02:57, Andy Lee wrote:
> 
>> Accessorizer's "Action Menu" is a status item that provides the exact UI 
>> Jerry is talking about
> 
> Thank you, Andy.
> 
> After thinking about what Kevin Callahan has done with Accessorizer, and the 
> suggestion by Graham and Seth, I have an answer that's even better than what 
> I was looking for.
> 
> Like Kevin's Accessorizer, which is a utility for Xcode, my app is a 
> bookmarking utility which, among other things, grabs sites from web browsers. 
>  Users want it to be accessible via a global keyboard shortcut while other 
> apps are active.  My original idea was to make this shortcut activate my 
> app's Status Item or Dock Menu.  But now I realize that, thanks to -[NSMenu 
> popUpMenuPositioningItem:atLocation:inView:] which was introduced in 10.6, I 
> don't need the damned Status Item or Dock Menu.  This is great, because the 
> same anti-mouse keyboard-aholic power users who want the global keyboard 
> shortcuts are generally the same users that hate Status Items and hate the 
> Dock.
> 
> So all I do is InstallApplicationEventHandler(), and RegisterEventHotKey() 
> with the user's preferred keyboard shortcut.  My handler invokes this 3-line 
> method which is implemented in the NSMenu subclass which I use for my Status 
> Item and Dock Menu…
> 
> - (void)popUpAnywhereMenu {
>NSPoint mouseLocation = [NSEvent mouseLocation] ;
>[self popUpMenuPositioningItem:[[self itemArray] objectAtIndex:0]
>atLocation:mouseLocation
>inView:nil] ;
> }
> 
> Hit the keyboard shortcut while in any web browser, and Poof!  My app's menu 
> appears, with keyboard focus, at the current mouse location on the screen.
> 
> I'll leave my Status Item Dock Menu as a preference option for the mouse 
> fans.  But I'm also keeping my Bug 10122120 open, because it's stupid that 
> the F8 shortcut can't access non-Apple Status Items.  We can't all be as 
> smart (or hacky as Charles suspects) as the bjango guys are.
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/aglee%40mac.com
> 
> This email sent to ag...@mac.com

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Give a menu keyboard focus – in code

2011-10-10 Thread Jerry Krinock

On 2011 Oct 10, at 02:57, Andy Lee wrote:

> Accessorizer's "Action Menu" is a status item that provides the exact UI 
> Jerry is talking about

Thank you, Andy.

After thinking about what Kevin Callahan has done with Accessorizer, and the 
suggestion by Graham and Seth, I have an answer that's even better than what I 
was looking for.

Like Kevin's Accessorizer, which is a utility for Xcode, my app is a 
bookmarking utility which, among other things, grabs sites from web browsers.  
Users want it to be accessible via a global keyboard shortcut while other apps 
are active.  My original idea was to make this shortcut activate my app's 
Status Item or Dock Menu.  But now I realize that, thanks to -[NSMenu 
popUpMenuPositioningItem:atLocation:inView:] which was introduced in 10.6, I 
don't need the damned Status Item or Dock Menu.  This is great, because the 
same anti-mouse keyboard-aholic power users who want the global keyboard 
shortcuts are generally the same users that hate Status Items and hate the Dock.

So all I do is InstallApplicationEventHandler(), and RegisterEventHotKey() with 
the user's preferred keyboard shortcut.  My handler invokes this 3-line method 
which is implemented in the NSMenu subclass which I use for my Status Item and 
Dock Menu…

- (void)popUpAnywhereMenu {
NSPoint mouseLocation = [NSEvent mouseLocation] ;
[self popUpMenuPositioningItem:[[self itemArray] objectAtIndex:0]
atLocation:mouseLocation
inView:nil] ;
}

Hit the keyboard shortcut while in any web browser, and Poof!  My app's menu 
appears, with keyboard focus, at the current mouse location on the screen.

I'll leave my Status Item Dock Menu as a preference option for the mouse fans.  
But I'm also keeping my Bug 10122120 open, because it's stupid that the F8 
shortcut can't access non-Apple Status Items.  We can't all be as smart (or 
hacky as Charles suspects) as the bjango guys are.

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Give a menu keyboard focus – in code

2011-10-10 Thread Charles Srstka
On Oct 10, 2011, at 7:34 AM, Jerry Krinock wrote:

> 
> On 2011 Oct 10, at 02:03, Martin Hewitson wrote:
> 
>> I haven't been following this thread closely, so I may be talking about the 
>> wrong thing here, but I just noticed I can cycle through the status items, 
>> and some of them (e.g. istat menus and apple items) are selectable with 
>> ctrl-f8 then arrow keys, and some not (e.g. dropbox). So it seems like it's 
>> possible, in principle. Don't know if that helps.
> 
> Thank you, Martin.  I have 7 non-Apple Status Items on my Mac account, and 
> none of them are accessible via the F8 key.  However, you are correct.  I 
> just installed iStat Menus from bjango.com and, indeed, its Status Items 
> *are* accessible via F8.  Furthermore, instead of being appended to the left, 
> they take priority over all the other non-Apple Status Items.  The right half 
> of my menu bar looks like this:
> 
>|  Other Non-Apple Items  |  iStat Menu Items  |  Apple Items 
> 
> Apparently, bjango has figured out a trick that no one else has.  I wonder if 
> it's "legal”?

It looks like they’re just using the private NSMenuExtra API. They’re probably 
using code injection to patch SystemUIServer to get around Apple’s protection 
to do so.

Not something I’d recommend.

Charles___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Give a menu keyboard focus – in code

2011-10-10 Thread Jerry Krinock

On 2011 Oct 10, at 02:03, Martin Hewitson wrote:

> I haven't been following this thread closely, so I may be talking about the 
> wrong thing here, but I just noticed I can cycle through the status items, 
> and some of them (e.g. istat menus and apple items) are selectable with 
> ctrl-f8 then arrow keys, and some not (e.g. dropbox). So it seems like it's 
> possible, in principle. Don't know if that helps.

Thank you, Martin.  I have 7 non-Apple Status Items on my Mac account, and none 
of them are accessible via the F8 key.  However, you are correct.  I just 
installed iStat Menus from bjango.com and, indeed, its Status Items *are* 
accessible via F8.  Furthermore, instead of being appended to the left, they 
take priority over all the other non-Apple Status Items.  The right half of my 
menu bar looks like this:

|  Other Non-Apple Items  |  iStat Menu Items  |  Apple Items 

Apparently, bjango has figured out a trick that no one else has.  I wonder if 
it's "legal"?

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Give a menu keyboard focus – in code

2011-10-10 Thread Andy Lee
On Oct 10, 2011, at 2:02 AM, Jerry Krinock wrote:
> On 2011 Oct 09, at 22:26, John Joyce wrote:
> 
>> For this reason, any menu item with a name can be assigned a keyboard 
>> shortcut in OS X System Preferences by the user.
> 
> Thank you, John, but it doesn't work for Status Items; not for me.
[...]
> Actually, even if it did work, that's not what I want.  Because my status 
> item's menu is populated dynamically, I want users to be able to navigate 
> through it with the arrow keys, like I can do with the Apple Status Items 
> after hitting the F8 key.

Accessorizer's "Action Menu" is a status item that provides the exact UI Jerry 
is talking about, and I think it is brilliant. Not only can you use arrow keys 
to navigate the menu once you've popped it up, but in Accessorizer there are a 
couple dozen menu items, all with keyboard shortcuts, and with this UI:

* You don't have to memorize all those shortcuts (although eventually you will 
remember the ones you use most frequently). All you have to remember is 
Accessorizer's one shortcut to pop up the menu, and the menu items within the 
menu display their shortcuts.

* It doesn't matter if the shortcuts conflict with shortcuts in any other 
application, because the status item's menu has focus when you pop it up. 
Compare this with keyboard shortcuts for Services, where a conflict can be a 
problem, especially if you have lots of them. Kevin Callahan came up with the 
Action Menu precisely because the menus in Xcode 4 use so many keyboard 
shortcuts, including many he had been using for the Services provided by 
Accessorizer.

* The keyboard shortcuts can be plain characters without modifiers, which makes 
them easy to type and remember. This wouldn't be possible if you had to worry 
that a text field might have focus, because the characters would get entered 
into the text field.

Gesturally and conceptually what Accessorizer does, and Jerry wants to do, is 
similar to Command-Tab: a globally-available special keystroke enters a mode 
that allows you to select from a bunch of items either with the mouse or with 
arrow keys. (One difference is that with Command-Tab you have to keep the 
Command key down while you navigate.) There are third-party apps like Alfred 
that are even more similar in concept.

There are tradeoffs for both the user and the developer between the Action Menu 
approach and the Alfred approach. For some reason I find Accessorizer's 
approach feels very natural and appropriate for what it does. I don't know how 
Kevin implements it, but I suspect it's by using a custom view in the status 
item as has been suggested.

--Andy

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Give a menu keyboard focus – in code

2011-10-10 Thread Martin Hewitson
I haven't been following this thread closely, so I may be talking about the 
wrong thing here, but I just noticed I can cycle through the status items, and 
some of them (e.g. istat menus and apple items) are selectable with ctrl-f8 
then arrow keys, and some not (e.g. dropbox). So it seems like it's possible, 
in principle. Don't know if that helps.

Martin


On Oct 10, 2011, at 02:02 AM, Jerry Krinock wrote:

> 
> On 2011 Oct 09, at 22:26, John Joyce wrote:
> 
>> For this reason, any menu item with a name can be assigned a keyboard 
>> shortcut in OS X System Preferences by the user.
> 
> Thank you, John, but it doesn't work for Status Items; not for me.
> 
> True, in System Preferences ▸ Keyboard ▸ Keyboard Shortcuts, I can create a 
> keyboard shortcut for any menu item with a name in the *main* menu.  And the 
> keyboard shortcut is even shown in that menu.  But it does not work for the 
> menus attached to non-Apple Status Items.  For example, I have a Dropbox 
> Status Item.  The first item in its menu is "Open Dropbox Folder".  I just 
> assigned this the keyboard shortcut ⇧⌥⌘O.  But the keyboard shortcut "⇧⌥⌘O" 
> is *not* showing in the Dropbox Status Item, and when I type ⇧⌥⌘O, all that 
> happens is a system alert beep.
> 
> Actually, even if it did work, that's not what I want.  Because my status 
> item's menu is populated dynamically, I want users to be able to navigate 
> through it with the arrow keys, like I can do with the Apple Status Items 
> after hitting the F8 key.
> 
> Maybe there is a reason why Apple does not want non-Apple Status Items to be 
> accessible to non-mouse-users.
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/martin.hewitson%40aei.mpg.de
> 
> This email sent to martin.hewit...@aei.mpg.de


Martin Hewitson
Albert-Einstein-Institut
Max-Planck-Institut fuer 
Gravitationsphysik und Universitaet Hannover
Callinstr. 38, 30167 Hannover, Germany
Tel: +49-511-762-17121, Fax: +49-511-762-5861
E-Mail: martin.hewit...@aei.mpg.de
WWW: http://www.aei.mpg.de/~hewitson






___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Give a menu keyboard focus – in code

2011-10-09 Thread Jerry Krinock

On 2011 Oct 09, at 22:26, John Joyce wrote:

> For this reason, any menu item with a name can be assigned a keyboard 
> shortcut in OS X System Preferences by the user.

Thank you, John, but it doesn't work for Status Items; not for me.

True, in System Preferences ▸ Keyboard ▸ Keyboard Shortcuts, I can create a 
keyboard shortcut for any menu item with a name in the *main* menu.  And the 
keyboard shortcut is even shown in that menu.  But it does not work for the 
menus attached to non-Apple Status Items.  For example, I have a Dropbox Status 
Item.  The first item in its menu is "Open Dropbox Folder".  I just assigned 
this the keyboard shortcut ⇧⌥⌘O.  But the keyboard shortcut "⇧⌥⌘O" is *not* 
showing in the Dropbox Status Item, and when I type ⇧⌥⌘O, all that happens is a 
system alert beep.

Actually, even if it did work, that's not what I want.  Because my status 
item's menu is populated dynamically, I want users to be able to navigate 
through it with the arrow keys, like I can do with the Apple Status Items after 
hitting the F8 key.

Maybe there is a reason why Apple does not want non-Apple Status Items to be 
accessible to non-mouse-users.

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Give a menu keyboard focus – in code

2011-10-09 Thread John Joyce

On Oct 9, 2011, at 10:09 PM, Jerry Krinock wrote:

> 
> On 2011 Oct 09, at 19:47, Graham Cox wrote:
> 
>> This all sounds like a generally terrible idea.
> 
> I think that my purpose of making my Status Item accessible from the keyboard 
> is quite noble, but I agree that the way I'm going about it is a terrible 
> kludge
> 
>> Have you checked to see whether the Accessibility APIs can give you what you 
>> want?
> 
> I'll look at the NSAccessibility protocol and read the Accessibility 
> Programming Guidelines.  If there are any other documents in particular I 
> should be reading, let me know
> 
>> If it's for some other purpose than accessibility
> 
> Well, I, and many users, even though we have functioning two hands, would 
> really like to be able to  access Status Items without using the mouse.  
> Unfortunately, the built-in F8 keyboard shortcut to "Focus on Status Items" 
> only cycles through the *Apple* status items.  (Filed a few weeks ago: Apple 
> Bug ID #10122120).
For this reason, any menu item with a name can be assigned a keyboard shortcut 
in OS X System Preferences by the user.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Give a menu keyboard focus – in code

2011-10-09 Thread Jerry Krinock

On 2011 Oct 09, at 19:47, Graham Cox wrote:

> This all sounds like a generally terrible idea.

I think that my purpose of making my Status Item accessible from the keyboard 
is quite noble, but I agree that the way I'm going about it is a terrible kludge

> Have you checked to see whether the Accessibility APIs can give you what you 
> want?

I'll look at the NSAccessibility protocol and read the Accessibility 
Programming Guidelines.  If there are any other documents in particular I 
should be reading, let me know

> If it's for some other purpose than accessibility

Well, I, and many users, even though we have functioning two hands, would 
really like to be able to  access Status Items without using the mouse.  
Unfortunately, the built-in F8 keyboard shortcut to "Focus on Status Items" 
only cycles through the *Apple* status items.  (Filed a few weeks ago: Apple 
Bug ID #10122120).

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Give a menu keyboard focus - in code

2011-10-09 Thread Jerry Krinock
OK, the CGEventCreateMouseEvent() I described in my previous message seems to 
work, except for one detail.  How to I find the location of, in particular, a 
Status Menu item, in CG "global" coordinates?  It looks like that's the hardest 
part!

Jerry

On 2011 Oct 09, at 14:16, Jerry Krinock wrote:

> Update: I'm "borrowing" the mouse using CGEventCreateMouseEvent().  It seems 
> like it might work, but sure seems like a kludge, and many lines of code to 
> do something very simple.
> 
> Any better ideas would be appreciated.
> 
> On 2011 Oct 09, at 12:31, Jerry Krinock wrote:
> 
>> Is there any code which can *click* a menu, to give it keyboard focus, so 
>> that the user may then select an item in the menu using arrow keys?


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Give a menu keyboard focus - in code

2011-10-09 Thread Jerry Krinock
Update: I'm "borrowing" the mouse using CGEventCreateMouseEvent().  It seems 
like it might work, but sure seems like a kludge, and many lines of code to do 
something very simple.

Any better ideas would be appreciated.

On 2011 Oct 09, at 12:31, Jerry Krinock wrote:

> Is there any code which can *click* a menu, to give it keyboard focus, so 
> that the user may then select an item in the menu using arrow keys?

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Give a menu keyboard focus - in code

2011-10-09 Thread Jerry Krinock
Is there any code which can *click* a menu, to give it keyboard focus, so that 
the user may then select an item in the menu using arrow keys?

Thanks a bunch!

Jerry

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com