Re: Bindings for dynamically populated menu
On 2014 Apr 09, at 10:22, Sean McBride s...@rogue-research.com wrote: A menu's selection is always visible, and I've found bindings on popup menus can be useful to deal with the selection. If the object represented by the popup's selection is deleted (by some other piece of UI) then the popup's selection can be updated automagically with bindings. You are correct, Sean. I was just thinking of Main Menu menus, and had forgotten about menus under popup buttons. I’ve used Cocoa Bindings not only on the Selected Whatever, but also Content and Content Values. But certainly the minute you want separators or other dynamic content, binding become less useful. Yes, the pain starts to rise. ___ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Bindings for dynamically populated menu
On Mon, 7 Apr 2014 07:01:19 -0700, Jerry Krinock said: Cocoa Bindings are useful to magically keep visible user interface elements in sync with data, although the magic comes with some pain, sometimes quite considerable. But menus only appear when the user clicks on them and disappear when the mouse goes up. Therefore it is natural to update menus, with menuNeedsUpdate:, when clicked, and there is no need to update them when they are not visible. Conclusion: Using Cocoa Bindings on menus is all pain for no gain. A menu's selection is always visible, and I've found bindings on popup menus can be useful to deal with the selection. If the object represented by the popup's selection is deleted (by some other piece of UI) then the popup's selection can be updated automagically with bindings. But certainly the minute you want separators or other dynamic content, binding become less useful. Cheers, -- Sean McBride, B. Eng s...@rogue-research.com Rogue Researchwww.rogue-research.com Mac Software Developer Montréal, Québec, Canada ___ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Bindings for dynamically populated menu
This must be a very basic question, but I am evidently having difficulty finding the right search terms. Can anyone point me to some sample code that will show how to implement a menu whose items are populated at runtime? I would have expected to be able to bind a menu object to an NSArray consisting of a series of menu item titles, but IB doesn't seem to offer any suitable binding names. Is there a way of doing that, or if not can anybody point me to some sample code that will show me what methods I need to override in my own subclass of NSMenu (if that's what I need to do). The menu will contain the names of however many suitable devices are connected to the machine at the time. Thanks in advance Jonny ___ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Bindings for dynamically populated menu
On 7 Apr 2014, at 11:25, Keith J. Schultz wrote: Hi Jonny, try Menu items on the fly! To my knowledge you can not use IB! Thanks for your reply keith. I hadn't tried those search terms, but no that didn't get me anything relevant either. All I could find was one old thread in which various conflicting advice is given and it is reported that one promising approach results in crashes: http://www.cocoabuilder.com/archive/cocoa/29044-cocoa-building-menu-on-the-fly.html However, more blind searching around has led me to NSMenuDelegate, which looks to me what I want... ___ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Bindings for dynamically populated menu
If wanting to build a menu on the fly I've been using the menuNeedsUpdate delegate method. The docs clearly state you can add/remove items this way. https://developer.apple.com/library/mac/documentation/cocoa/reference/NSMenuDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intfm/NSMenuDelegate/menuNeedsUpdate: ___m i c h a e l s t a r k e geschäftsführer HicknHack Software GmbH www.hicknhack-software.com ___k o n t a k t +49 (170) 36 86 1 36 cont...@hicknhack.com ___H i c k n H a c k S o f t w a r e G m b H geschäftsführer - maik lathan | andreas reischuck | michael starke bayreuther straße 32 01187 dresden amtsgericht dresden HRB 30351 sitz - dresden On 07.04.2014, at 12:43, Jonathan Taylor jonathan.tay...@glasgow.ac.uk wrote: On 7 Apr 2014, at 11:25, Keith J. Schultz wrote: Hi Jonny, try Menu items on the fly! To my knowledge you can not use IB! Thanks for your reply keith. I hadn't tried those search terms, but no that didn't get me anything relevant either. All I could find was one old thread in which various conflicting advice is given and it is reported that one promising approach results in crashes: http://www.cocoabuilder.com/archive/cocoa/29044-cocoa-building-menu-on-the-fly.html However, more blind searching around has led me to NSMenuDelegate, which looks to me what I want... ___ 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: https://lists.apple.com/mailman/options/cocoa-dev/michael.starke%40hicknhack-software.com This email sent to michael.sta...@hicknhack-software.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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Bindings for dynamically populated menu
On 2014 Apr 07, at 03:49, Michael Starke michael.sta...@hicknhack-software.com wrote: If wanting to build a menu on the fly I've been using the menuNeedsUpdate delegate method. Michael’s advice is correct. Cocoa Bindings are useful to magically keep visible user interface elements in sync with data, although the magic comes with some pain, sometimes quite considerable. But menus only appear when the user clicks on them and disappear when the mouse goes up. Therefore it is natural to update menus, with menuNeedsUpdate:, when clicked, and there is no need to update them when they are not visible. Conclusion: Using Cocoa Bindings on menus is all pain for no gain. ___ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com