Re: Dynamically populate a popup menu

2010-02-17 Thread Peter N Lewis
On 17/02/2010, at 15:53 , Graham Cox wrote:
> On 17/02/2010, at 6:49 PM, Peter N Lewis wrote:
> 
>> Is there any way to dynamically populate a popup menu on the fly (as it is 
>> exposed)?
> 
> Look into the NSMenuDelegate protocol. It has methods to do what you want.

Yes, that looks like it will do what I need.  Hopefully the code will be fast 
enough to just use 

- (void)menuNeedsUpdate:(NSMenu *)menu

otherwise I'll have to do a bit more work to get

- (NSInteger)numberOfItemsInMenu:(NSMenu *)menu
- (BOOL)menu:(NSMenu *)menu updateItem:(NSMenuItem *)item 
atIndex:(NSInteger)index shouldCancel:(BOOL)shouldCancel

working.

And I did know about NSPopUpButtonWillPopUpNotification, and indeed that was 
what I was using, but unfortunately it was taking about a minute to populate 
the menu, and therein lies the problem.

The menu is only about three or four levels deep in the normal case, and a menu 
selection is definitely the right UI for this use case, not a browser or some 
other mechanism.  About the only other good UI would be a big custom UI 
designed specifically for this use, and that's more work than I want for little 
or no gain in usability.

Thanks for the comments!
Peter.

-- 
 Keyboard Maestro 4.0.2 now released!  Brand new interface!

Keyboard Maestro <http://www.keyboardmaestro.com/> Macros for your Mac
<http://www.stairways.com/>   <http://download.stairways.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: Dynamically populate a popup menu

2010-02-17 Thread Graham Cox

On 18/02/2010, at 3:00 AM, Steven Degutis wrote:

> While NSMenuDelegate isn't wrong per se, I still prefer to use the
> NSPopUpButton's notification myself. Touching the button's internal menu
> seems like dipping my fingers where they don't belong.


NSMenuDelegate works fine with pop-up buttons. If the button's menu has dynamic 
content, how are you going to achieve it without 'dipping your fingers' into 
its menu? That's why it has a public -menu method, which you'd have to use from 
your notification handler anyway. The delegate approach is more direct and the 
supported way to do this.

--Graham


___

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: Dynamically populate a popup menu

2010-02-17 Thread Jean-Daniel Dupas
Yes, but using the notification does not solve the OP problem that is:

I have to much submenu and item to compute then at one time.

Not to mention the fact that he asked for a popup menu, but he does not talk 
about a popup button.

That said, having more than one level of submenu is again Interface Guidelines 
(see "Hierarchical Menus (Submenus)" section in Interface Guidelines):

"Because submenus add complexity to the interface and are physically more 
difficult to use, you should use them only when you have more menus than fit in 
the menu bar or for closely related commands. Use only one level of submenus. 
If a submenu contains more than five items, consider giving it its own menu."

Using a Menu to browser the disk is maybe not the way to go.


Le 17 févr. 2010 à 17:00, Steven Degutis a écrit :

> While NSMenuDelegate isn't wrong per se, I still prefer to use the 
> NSPopUpButton's notification myself. Touching the button's internal menu 
> seems like dipping my fingers where they don't belong.
> 
> -Steven
> 
> On Wed, Feb 17, 2010 at 10:41 AM, Jean-Daniel Dupas  
> wrote:
> 
> See NSMenuDelegate protocol.
> There is some method to dynamically populate the menu.
> 
> Le 17 févr. 2010 à 16:09, Steven Degutis a écrit :
> 
> > Check out NSPopUpButton's NSPopUpButtonWillPopUpNotification
> >
> > On Wed, Feb 17, 2010 at 2:49 AM, Peter N Lewis 
> > wrote:
> >
> >> Is there any way to dynamically populate a popup menu on the fly (as it is
> >> exposed)?
> >>
> >> For example, a popup menu that displayed the harddisk hierarchy would need
> >> this sort of thing - you wouldn't want the entire thing populated as soon 
> >> as
> >> you click the popup menu, it would take forever and the user would never 
> >> see
> >> most of it.
> >>
> >> Can it be done by subclassing NSMenuItem etc?
> >>
> >> The only alternative I can see would be some sort of custom control based
> >> on NSBrowser, but that would be a lot uglier for this sort of selection.
> >>
> >> Thanks,
> >>  Peter.
> >>
> >> --
> >>Keyboard Maestro 4.0.2 now released!  Brand new interface!
> >>
> >> Keyboard Maestro <http://www.keyboardmaestro.com/> Macros for your Mac
> >> <http://www.stairways.com/>   <http://download.stairways.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/steven.degutis%40gmail.com
> >>
> >> This email sent to steven.degu...@gmail.com
> >>
> >
> >
> >
> > --
> > Steven Degutis
> > http://www.thoughtfultree.com/
> > http://www.degutis.org/
> > ___
> >
> > 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/devlists%40shadowlab.org
> >
> > This email sent to devli...@shadowlab.org
> 
> -- Jean-Daniel
> 
> 
> 
> 
> 
> 
> 
> -- 
> Steven Degutis
> http://www.thoughtfultree.com/
> http://www.degutis.org/

-- Jean-Daniel




___

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: Dynamically populate a popup menu

2010-02-17 Thread Steven Degutis
While NSMenuDelegate isn't wrong per se, I still prefer to use the
NSPopUpButton's notification myself. Touching the button's internal menu
seems like dipping my fingers where they don't belong.

-Steven

On Wed, Feb 17, 2010 at 10:41 AM, Jean-Daniel Dupas
wrote:

>
> See NSMenuDelegate protocol.
> There is some method to dynamically populate the menu.
>
> Le 17 févr. 2010 à 16:09, Steven Degutis a écrit :
>
> > Check out NSPopUpButton's NSPopUpButtonWillPopUpNotification
> >
> > On Wed, Feb 17, 2010 at 2:49 AM, Peter N Lewis  >wrote:
> >
> >> Is there any way to dynamically populate a popup menu on the fly (as it
> is
> >> exposed)?
> >>
> >> For example, a popup menu that displayed the harddisk hierarchy would
> need
> >> this sort of thing - you wouldn't want the entire thing populated as
> soon as
> >> you click the popup menu, it would take forever and the user would never
> see
> >> most of it.
> >>
> >> Can it be done by subclassing NSMenuItem etc?
> >>
> >> The only alternative I can see would be some sort of custom control
> based
> >> on NSBrowser, but that would be a lot uglier for this sort of selection.
> >>
> >> Thanks,
> >>  Peter.
> >>
> >> --
> >>Keyboard Maestro 4.0.2 now released!  Brand new interface!
> >>
> >> Keyboard Maestro <http://www.keyboardmaestro.com/> Macros for your Mac
> >> <http://www.stairways.com/>   <http://download.stairways.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/steven.degutis%40gmail.com
> >>
> >> This email sent to steven.degu...@gmail.com
> >>
> >
> >
> >
> > --
> > Steven Degutis
> > http://www.thoughtfultree.com/
> > http://www.degutis.org/
> > ___
> >
> > 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/devlists%40shadowlab.org
> >
> > This email sent to devli...@shadowlab.org
>
> -- Jean-Daniel
>
>
>
>
>


-- 
Steven Degutis
http://www.thoughtfultree.com/
http://www.degutis.org/
___

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: Dynamically populate a popup menu

2010-02-17 Thread Jean-Daniel Dupas

See NSMenuDelegate protocol.
There is some method to dynamically populate the menu.

Le 17 févr. 2010 à 16:09, Steven Degutis a écrit :

> Check out NSPopUpButton's NSPopUpButtonWillPopUpNotification
> 
> On Wed, Feb 17, 2010 at 2:49 AM, Peter N Lewis wrote:
> 
>> Is there any way to dynamically populate a popup menu on the fly (as it is
>> exposed)?
>> 
>> For example, a popup menu that displayed the harddisk hierarchy would need
>> this sort of thing - you wouldn't want the entire thing populated as soon as
>> you click the popup menu, it would take forever and the user would never see
>> most of it.
>> 
>> Can it be done by subclassing NSMenuItem etc?
>> 
>> The only alternative I can see would be some sort of custom control based
>> on NSBrowser, but that would be a lot uglier for this sort of selection.
>> 
>> Thanks,
>>  Peter.
>> 
>> --
>>Keyboard Maestro 4.0.2 now released!  Brand new interface!
>> 
>> Keyboard Maestro <http://www.keyboardmaestro.com/> Macros for your Mac
>> <http://www.stairways.com/>   <http://download.stairways.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/steven.degutis%40gmail.com
>> 
>> This email sent to steven.degu...@gmail.com
>> 
> 
> 
> 
> -- 
> Steven Degutis
> http://www.thoughtfultree.com/
> http://www.degutis.org/
> ___
> 
> 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/devlists%40shadowlab.org
> 
> This email sent to devli...@shadowlab.org

-- Jean-Daniel




___

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: Dynamically populate a popup menu

2010-02-17 Thread Steven Degutis
Check out NSPopUpButton's NSPopUpButtonWillPopUpNotification

On Wed, Feb 17, 2010 at 2:49 AM, Peter N Lewis wrote:

> Is there any way to dynamically populate a popup menu on the fly (as it is
> exposed)?
>
> For example, a popup menu that displayed the harddisk hierarchy would need
> this sort of thing - you wouldn't want the entire thing populated as soon as
> you click the popup menu, it would take forever and the user would never see
> most of it.
>
> Can it be done by subclassing NSMenuItem etc?
>
> The only alternative I can see would be some sort of custom control based
> on NSBrowser, but that would be a lot uglier for this sort of selection.
>
> Thanks,
>   Peter.
>
> --
> Keyboard Maestro 4.0.2 now released!  Brand new interface!
>
> Keyboard Maestro <http://www.keyboardmaestro.com/> Macros for your Mac
> <http://www.stairways.com/>   <http://download.stairways.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/steven.degutis%40gmail.com
>
> This email sent to steven.degu...@gmail.com
>



-- 
Steven Degutis
http://www.thoughtfultree.com/
http://www.degutis.org/
___

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: Dynamically populate a popup menu

2010-02-16 Thread Graham Cox

On 17/02/2010, at 6:49 PM, Peter N Lewis wrote:

> Is there any way to dynamically populate a popup menu on the fly (as it is 
> exposed)?

Look into the NSMenuDelegate protocol. It has methods to do what you want.



--Graham___

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


Dynamically populate a popup menu

2010-02-16 Thread Peter N Lewis
Is there any way to dynamically populate a popup menu on the fly (as it is 
exposed)?

For example, a popup menu that displayed the harddisk hierarchy would need this 
sort of thing - you wouldn't want the entire thing populated as soon as you 
click the popup menu, it would take forever and the user would never see most 
of it.

Can it be done by subclassing NSMenuItem etc?

The only alternative I can see would be some sort of custom control based on 
NSBrowser, but that would be a lot uglier for this sort of selection.

Thanks,
   Peter.

-- 
 Keyboard Maestro 4.0.2 now released!  Brand new interface!

Keyboard Maestro <http://www.keyboardmaestro.com/> Macros for your Mac
<http://www.stairways.com/>   <http://download.stairways.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