Re: NSPopupUpButton not showing checked menu items
On Nov 23, 2008, at 11:26 PM, Benjamin Dobson wrote: Actually, I only wanted to select a single item in the pulldown case, the same as what correctly happens for me in the popup case. The problem has always been that, even though the button itself is reporting that a particular item is "selected," none of the underlying NSMenuItems' state is ever set to anything other than where it was left in IB (which is typically NSOffState). And so a check mark is never set next to the most-recently selected menu item. I'm still wondering why you're using a pull down menu, not a pop up one. Very simply because I have a situation where real estate is tight. The popup variant always displays the current selection so you need to allocate enough horizontal space for the button to display the widest menu item text. By using the pulldown button, I can just display an icon and "down arrow" on the button, and use more space only when the user changes options. I have a descriptive icon next to each menu item, which gets reflected directly on the button when the menu is closed. Believe me, if I could do something similar with a popup (vs pulldown) button, I would. Much less work. steve ___ 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 [EMAIL PROTECTED]
Re: NSPopupUpButton not showing checked menu items
On Nov 24, 2008, at 1:21 PM, Steve Christensen wrote: On Nov 24, 2008, at 12:53 PM, Peter Ammon wrote: On Nov 23, 2008, at 3:33 PM, Steve Christensen wrote: On Nov 23, 2008, at 3:05 PM, Kyle Sluder wrote: On Sun, Nov 23, 2008 at 6:01 PM, Steve Christensen <[EMAIL PROTECTED]> wrote: The class methods also don't make a distinction between popup and pulldown, so I would think that the "selection" should still be marked in the menu when it's visible. I'm not trying to be argumentative, just wondering if I have, in fact, made a good or bad assumption about behavior given how every other menu I've seen works. I suppose I could manually set the individual menu item states but that seems like work I shouldn't need to do. I think you have made a bad assumption. The selection bindings for NSPopupButton consist of selectedIndex, selectedObject, selectedTag, and selectedValue. In order to support multiple selected items, NSPopupButton would need a selectionIndexes binding. Actually, I only wanted to select a single item in the pulldown case, the same as what correctly happens for me in the popup case. The problem has always been that, even though the button itself is reporting that a particular item is "selected," none of the underlying NSMenuItems' state is ever set to anything other than where it was left in IB (which is typically NSOffState). And so a check mark is never set next to the most-recently selected menu item. Pull-down popups are used for commands, like a context menu, and therefore pull-down popups do not change the state of the selected item. This is by design, since the commands are assumed to be stateless. If you want to change the state of the menu item, you can do so manually, but you might consider using a regular popup button or a different control entirely. A pull-down popup that acts like a matrix of radio buttons is a departure from Apple's HIG. Well, I was specifically using the pulldown mode because I wanted a control that would take up less space most of the time. In the closed state, it's pretty much a button with a small icon (reflecting the current option) and a down-arrow; clicking on the button reveals a larger popup with a set of options. I ended up setting and clearing checkmarks manually, which works fine but was unexpected work. The NSPopUpButton class specifies both methods and bindings for specifying the "selected item" regardless of popup/pulldown control type. And since the API docs don't call out any differences in behavior, I ended up wasting time trying to figure out why my bindings weren't working "correctly." Whether an item is selected is distinct from its state - see the NSPopUpButtonCell method setAltersStateOfSelectedItem:. This setting is always treated as false for pull-down popups. It sounds like the docs aren't very clear on this. Please do file a bug report for clarifying the documentation. Thanks! -Peter ___ 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 [EMAIL PROTECTED]
Re: NSPopupUpButton not showing checked menu items
On Nov 24, 2008, at 12:53 PM, Peter Ammon wrote: On Nov 23, 2008, at 3:33 PM, Steve Christensen wrote: On Nov 23, 2008, at 3:05 PM, Kyle Sluder wrote: On Sun, Nov 23, 2008 at 6:01 PM, Steve Christensen <[EMAIL PROTECTED]> wrote: The class methods also don't make a distinction between popup and pulldown, so I would think that the "selection" should still be marked in the menu when it's visible. I'm not trying to be argumentative, just wondering if I have, in fact, made a good or bad assumption about behavior given how every other menu I've seen works. I suppose I could manually set the individual menu item states but that seems like work I shouldn't need to do. I think you have made a bad assumption. The selection bindings for NSPopupButton consist of selectedIndex, selectedObject, selectedTag, and selectedValue. In order to support multiple selected items, NSPopupButton would need a selectionIndexes binding. Actually, I only wanted to select a single item in the pulldown case, the same as what correctly happens for me in the popup case. The problem has always been that, even though the button itself is reporting that a particular item is "selected," none of the underlying NSMenuItems' state is ever set to anything other than where it was left in IB (which is typically NSOffState). And so a check mark is never set next to the most-recently selected menu item. Pull-down popups are used for commands, like a context menu, and therefore pull-down popups do not change the state of the selected item. This is by design, since the commands are assumed to be stateless. If you want to change the state of the menu item, you can do so manually, but you might consider using a regular popup button or a different control entirely. A pull-down popup that acts like a matrix of radio buttons is a departure from Apple's HIG. Well, I was specifically using the pulldown mode because I wanted a control that would take up less space most of the time. In the closed state, it's pretty much a button with a small icon (reflecting the current option) and a down-arrow; clicking on the button reveals a larger popup with a set of options. I ended up setting and clearing checkmarks manually, which works fine but was unexpected work. The NSPopUpButton class specifies both methods and bindings for specifying the "selected item" regardless of popup/pulldown control type. And since the API docs don't call out any differences in behavior, I ended up wasting time trying to figure out why my bindings weren't working "correctly." steve ___ 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 [EMAIL PROTECTED]
Re: NSPopupUpButton not showing checked menu items
On Nov 23, 2008, at 3:33 PM, Steve Christensen wrote: On Nov 23, 2008, at 3:05 PM, Kyle Sluder wrote: On Sun, Nov 23, 2008 at 6:01 PM, Steve Christensen <[EMAIL PROTECTED]> wrote: The class methods also don't make a distinction between popup and pulldown, so I would think that the "selection" should still be marked in the menu when it's visible. I'm not trying to be argumentative, just wondering if I have, in fact, made a good or bad assumption about behavior given how every other menu I've seen works. I suppose I could manually set the individual menu item states but that seems like work I shouldn't need to do. I think you have made a bad assumption. The selection bindings for NSPopupButton consist of selectedIndex, selectedObject, selectedTag, and selectedValue. In order to support multiple selected items, NSPopupButton would need a selectionIndexes binding. Actually, I only wanted to select a single item in the pulldown case, the same as what correctly happens for me in the popup case. The problem has always been that, even though the button itself is reporting that a particular item is "selected," none of the underlying NSMenuItems' state is ever set to anything other than where it was left in IB (which is typically NSOffState). And so a check mark is never set next to the most-recently selected menu item. Hi Steve, Pull-down popups are used for commands, like a context menu, and therefore pull-down popups do not change the state of the selected item. This is by design, since the commands are assumed to be stateless. If you want to change the state of the menu item, you can do so manually, but you might consider using a regular popup button or a different control entirely. A pull-down popup that acts like a matrix of radio buttons is a departure from Apple's HIG. -Peter ___ 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 [EMAIL PROTECTED]
Re: NSPopupUpButton not showing checked menu items
Actually, I only wanted to select a single item in the pulldown case, the same as what correctly happens for me in the popup case. The problem has always been that, even though the button itself is reporting that a particular item is "selected," none of the underlying NSMenuItems' state is ever set to anything other than where it was left in IB (which is typically NSOffState). And so a check mark is never set next to the most-recently selected menu item. I'm still wondering why you're using a pull down menu, not a pop up one. ___ 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 [EMAIL PROTECTED]
Re: NSPopupUpButton not showing checked menu items
On Nov 23, 2008, at 3:05 PM, Kyle Sluder wrote: On Sun, Nov 23, 2008 at 6:01 PM, Steve Christensen <[EMAIL PROTECTED]> wrote: The class methods also don't make a distinction between popup and pulldown, so I would think that the "selection" should still be marked in the menu when it's visible. I'm not trying to be argumentative, just wondering if I have, in fact, made a good or bad assumption about behavior given how every other menu I've seen works. I suppose I could manually set the individual menu item states but that seems like work I shouldn't need to do. I think you have made a bad assumption. The selection bindings for NSPopupButton consist of selectedIndex, selectedObject, selectedTag, and selectedValue. In order to support multiple selected items, NSPopupButton would need a selectionIndexes binding. Actually, I only wanted to select a single item in the pulldown case, the same as what correctly happens for me in the popup case. The problem has always been that, even though the button itself is reporting that a particular item is "selected," none of the underlying NSMenuItems' state is ever set to anything other than where it was left in IB (which is typically NSOffState). And so a check mark is never set next to the most-recently selected menu item. I'd suggest filing an enhancement request, describing what you want to do and asking that the selection bindings either be documented to return the first selected item in the case of multiple selected items, or that NSPopupButton expose a selectionIndexes binding. No enhancement request needed. I'm seeing apparently inconsistent behavior between the popup and pulldown cases. I'm certainly willing to concede that I've goofed someplace, but if so it's not at all obvious (and thus the questions). :) steve ___ 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 [EMAIL PROTECTED]
Re: NSPopupUpButton not showing checked menu items
On Sun, Nov 23, 2008 at 6:01 PM, Steve Christensen <[EMAIL PROTECTED]> wrote: > The class methods also don't make a distinction between popup and pulldown, > so I would think that the "selection" should still be marked in the menu > when it's visible. I'm not trying to be argumentative, just wondering if I > have, in fact, made a good or bad assumption about behavior given how every > other menu I've seen works. I suppose I could manually set the individual > menu item states but that seems like work I shouldn't need to do. I think you have made a bad assumption. The selection bindings for NSPopupButton consist of selectedIndex, selectedObject, selectedTag, and selectedValue. In order to support multiple selected items, NSPopupButton would need a selectionIndexes binding. I'd suggest filing an enhancement request, describing what you want to do and asking that the selection bindings either be documented to return the first selected item in the case of multiple selected items, or that NSPopupButton expose a selectionIndexes binding. --Kyle Sluder ___ 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 [EMAIL PROTECTED]
Re: NSPopupUpButton not showing checked menu items
On Nov 23, 2008, at 1:14 PM, Kyle Sluder wrote: On Sun, Nov 23, 2008 at 4:09 PM, Steve Christensen <[EMAIL PROTECTED]> wrote: Yes, but I would expect that the current selection would be shown as checked in the pulldown menu when the button is clicked. I don't think "selection" makes sense for pull-down items. You treat a pull-down menu like a collection of menu items, not like a matrix of radio buttons. "An NSPopUpButton object controls a pop-up menu or a pull-down menu from which a user can select an item." The class methods also don't make a distinction between popup and pulldown, so I would think that the "selection" should still be marked in the menu when it's visible. I'm not trying to be argumentative, just wondering if I have, in fact, made a good or bad assumption about behavior given how every other menu I've seen works. I suppose I could manually set the individual menu item states but that seems like work I shouldn't need to do. steve ___ 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 [EMAIL PROTECTED]
Re: NSPopupUpButton not showing checked menu items
On Sun, Nov 23, 2008 at 4:09 PM, Steve Christensen <[EMAIL PROTECTED]> wrote: > Yes, but I would expect that the current selection would be shown as checked > in the pulldown menu when the button is clicked. I don't think "selection" makes sense for pull-down items. You treat a pull-down menu like a collection of menu items, not like a matrix of radio buttons. --Kyle Sluder ___ 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 [EMAIL PROTECTED]
Re: NSPopupUpButton not showing checked menu items
On Nov 23, 2008, at 1:02 PM, Kyle Sluder wrote: On Sun, Nov 23, 2008 at 3:27 PM, Steve Christensen <[EMAIL PROTECTED]> wrote: I'm not at all sure that my confusion is stemming from a bindings issue, though. I've attached an archived project with both popup and pulldown menu buttons in a window. The popup works as expected, but the pulldown seems stuck for some reason. You are aware that pull-down menus don't change their selection like pop-up menus do? Yes, but I would expect that the current selection would be shown as checked in the pulldown menu when the button is clicked. ___ 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 [EMAIL PROTECTED]
Re: NSPopupUpButton not showing checked menu items
On Sun, Nov 23, 2008 at 3:27 PM, Steve Christensen <[EMAIL PROTECTED]> wrote: > I'm not at all sure that my confusion is stemming from a bindings issue, > though. I've attached an archived project with both popup and pulldown menu > buttons in a window. The popup works as expected, but the pulldown seems > stuck for some reason. You are aware that pull-down menus don't change their selection like pop-up menus do? --Kyle Sluder ___ 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 [EMAIL PROTECTED]
Re: NSPopupUpButton not showing checked menu items
On Sun, Nov 23, 2008 at 10:51 AM, Steve Christensen <[EMAIL PROTECTED]> wrote: > - (void) setInterpolationMode:(NSInteger)mode > { >[self willChangeValueForKey:@"interpolationMode"]; >_interpolationMode = mode; >[self didChangeValueForKey:@"interpolationMode"]; > >// set the title image to that of the current mode >[[_interpolationModePopup itemAtIndex:0] > setImage:_interpolationImages[mode]]; > } > >> Additionally, are you overriding +automaticallyNotifiesObserversForKey: or > > No. If you are not overriding +automaticallyNotifiesObserversForKey:, then why are you manually sending -willChangeValueForKey: and -didChangeValueForKey:? You are already benefitting from automatic KVO support (assuming your accessor is named -interpolationMode). -willChangeValueForKey: and -didChangeValueForKey: are only for manual KVO support, which requires overriding +automaticallyNotifiesObserversForKey: to return NO for the key in question: http://developer.apple.com/documentation/Cocoa/Conceptual/KeyValueObserving/Concepts/AutoVsManual.html#//apple_ref/doc/uid/20001844-178876 >> sending +setKeys:triggerChangeNotificationsForDependentKey: anywhere? > > Yes, for a couple of other controller keys that are dependent on the one > above. > They get set in my controller's +initialize method. The reason I ask these questions is so that by examining your code, we may figure out what's going wrong. The crucial step in this process is the posting of code. ;-) --Kyle Sluder ___ 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 [EMAIL PROTECTED]
Re: NSPopupUpButton not showing checked menu items
On Nov 23, 2008, at 12:13 AM, Kyle Sluder wrote: On Sun, Nov 23, 2008 at 12:45 AM, Steve Christensen <[EMAIL PROTECTED]> wrote: When I click on the popup and change the selection, the result I'm seeing is that my controller's setter method is being called, that the popup's selected item index is being changed correctly (at least NSLog says so), but that the currently selected menu item isn't checked. Please post the code for your controller's setter method. - (void) setInterpolationMode:(NSInteger)mode { [self willChangeValueForKey:@"interpolationMode"]; _interpolationMode = mode; [self didChangeValueForKey:@"interpolationMode"]; // set the title image to that of the current mode [[_interpolationModePopup itemAtIndex:0] setImage:_interpolationImages[mode]]; } Additionally, are you overriding +automaticallyNotifiesObserversForKey: or No. sending +setKeys:triggerChangeNotificationsForDependentKey: anywhere? Yes, for a couple of other controller keys that are dependent on the one above. They get set in my controller's +initialize method. steve ___ 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 [EMAIL PROTECTED]
Re: NSPopupUpButton not showing checked menu items
On Sun, Nov 23, 2008 at 12:45 AM, Steve Christensen <[EMAIL PROTECTED]> wrote: > When I click on the popup and change the selection, the result I'm seeing is > that my controller's setter method is being called, that the popup's > selected item index is being changed correctly (at least NSLog says so), but > that the currently selected menu item isn't checked. Please post the code for your controller's setter method. Additionally, are you overriding +automaticallyNotifiesObserversForKey: or sending +setKeys:triggerChangeNotificationsForDependentKey: anywhere? --Kyle Sluder ___ 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 [EMAIL PROTECTED]
Re: NSPopupUpButton not showing checked menu items
On Nov 22, 2008, at 6:38 PM, Kyle Sluder wrote: On Sat, Nov 22, 2008 at 9:20 PM, Steve Christensen <[EMAIL PROTECTED]> wrote: In IB I created a NSPopUpButton configured as pulldown with a static menu. I bound its selectedTag binding to a method on my window controller. (I also tried binding selectedIndex with the same results.) When I run my code and select various of the items in the button's menu, none of the items are shown as checked. Or if one of the menu items was left "selected" in IB from when items were added to the menu, that item is permanently checked. You bound "selectedTag" to a method? Bindings are done to keypaths. Of course, they key can be implemented using KVO-compliant accessor and mutator methods -- is this how you have done it? Sorry, I was inaccurate. Yes, I specified that the NSPopupButton's selectedTag binding will get/set its value based on a key path associated with my window controller class (also nib file owner). In my particular case, the binding is to a getter/setter pair of methods since I have to do a little more than simply getting or setting an instance variable. When I click on the popup and change the selection, the result I'm seeing is that my controller's setter method is being called, that the popup's selected item index is being changed correctly (at least NSLog says so), but that the currently selected menu item isn't checked. steve ___ 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 [EMAIL PROTECTED]
Re: NSPopupUpButton not showing checked menu items
On Sat, Nov 22, 2008 at 9:20 PM, Steve Christensen <[EMAIL PROTECTED]> wrote: > In IB I created a NSPopUpButton configured as pulldown with a static menu. I > bound its selectedTag binding to a method on my window controller. (I also > tried binding selectedIndex with the same results.) When I run my code and > select various of the items in the button's menu, none of the items are > shown as checked. Or if one of the menu items was left "selected" in IB from > when items were added to the menu, that item is permanently checked. You bound "selectedTag" to a method? Bindings are done to keypaths. Of course, they key can be implemented using KVO-compliant accessor and mutator methods -- is this how you have done it? --Kyle Sluder ___ 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 [EMAIL PROTECTED]