NSMenuItem: setState not working as expected
NSMenuItem: setState not working as expected
- Subject: NSMenuItem: setState not working as expected
- From: Bill Allaire <email@hidden>
- Date: Tue, 25 Sep 2007 23:39:25 -0400
I have a NSSearchField which is connected to a NSMenu by way of the
searchMenuTemplate in IB (Interface Builder). The menu is working
great in that the recently searched items show up, the two
NSMenuItems items created to make use of
NSSearchFieldClearRecentsMenuItemTag and
NSSearchFieldNoRecentsMenuItemTag all work well and as expected. I
followed "Introduction to Search Fields" to accomplish this.
The last feature I wanted to add to this menu is to allow the user to
select which column (all or pick an individual column from the menu)
to filter content, somewhat similar to what is in iTunes and its
search box with a choice of "All" or "Album" or "Artist", etc. I
added three NSMenuItems to the NSMenu and titled them accordingly and
gave each a different tag starting at 1 and ending at 3. All three
share the same target. The first NSMenuItem is set to a state of
"On". The other two are set to a state of "Off".
Here is a sample of state change. There are three NSMenuItems items
(in addition to the above mentioned items):
- Search All (initial state set to "On" via IB)
- Command (intial state set to "Off" via IB)
- Connection (ditto)
Run application. Pull down menu from the search field and choose,
say, Connection. The target method logs the state of "Search All" as
NSOnState. The target method sets the state for "Connection" to
NSOnState. It then sets the state of "Search All" to NSOffState with
the intent of removing the check mark beside it, leaving "Connection"
as the only item with a check mark. I then log the state of "Search
All" after the state change and at this point and it shows
NSOffState. So far so good. I pull the menu down again and both
"Search All" and "Connection" have check marks. Not good. I also
notice that if I click back on "Search All", to turn it to an on
state, the logging, which logs the state before and after the call to
setState:, shows no change in state! Like it's not responding to the
message being sent.
I suspect there is something going on with how the NSSearchField is
using this menu that I don't understand.
Bill
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden