FROM : Matt Neuburg
DATE : Wed Jul 19 21:36:56 2006
On Wed, 19 Jul 2006 19:30:47 +0200, malcom <malcom.<email_removed>> said:
>Hi list,
>I would to add a categories menu (ex: search for Subject, Body or ...)
>in my NSSearchField. I've successfully set the menu but there is a
>problem if I try to set a menuitem to state:NSOffState.
>When I select a menu it should be to turn off the previous selected
>category. This is the code:
>
>- (IBAction) menu_selectNewFilter:(id) sender {
>
> NSMenuItem *m = [searchMenu itemWithTag: selectedFilter];
> [m setState: NSOffState];
> NSLog(@"Disabled %@ %d",[m title],[m tag]);
>
> NSLog(@"Activate %@ %d",[sender title],[sender tag]);
> [sender setState: NSOnState];
>
> selectedFilter = [sender tag];
>}
>
>It works for ONState but the previous item state will never change
>(I've also tried to take a look at the debugger and, in fact the state
>of NSOffState menuitem is 0...but the checkmark icon still here!).
>Is there a problem with this class or is it a problem of mine?
What I did in a similar situation (in my Thucydides app) was simply to
implement validateMenuItem. In this way I was able to achieve some pretty
elaborate combinations of enabling and checking. The download includes the
source code if you want to examine it; the one you want is the original,
Panther version ("Thucydides"), not the Tiger "ThucydidesCoreDate" one (in
which I abandoned the search field menu - I think it's a rather poor piece
of interface no matter how you slice it). m.
--
matt neuburg, phd = <email_removed>, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>
DATE : Wed Jul 19 21:36:56 2006
On Wed, 19 Jul 2006 19:30:47 +0200, malcom <malcom.<email_removed>> said:
>Hi list,
>I would to add a categories menu (ex: search for Subject, Body or ...)
>in my NSSearchField. I've successfully set the menu but there is a
>problem if I try to set a menuitem to state:NSOffState.
>When I select a menu it should be to turn off the previous selected
>category. This is the code:
>
>- (IBAction) menu_selectNewFilter:(id) sender {
>
> NSMenuItem *m = [searchMenu itemWithTag: selectedFilter];
> [m setState: NSOffState];
> NSLog(@"Disabled %@ %d",[m title],[m tag]);
>
> NSLog(@"Activate %@ %d",[sender title],[sender tag]);
> [sender setState: NSOnState];
>
> selectedFilter = [sender tag];
>}
>
>It works for ONState but the previous item state will never change
>(I've also tried to take a look at the debugger and, in fact the state
>of NSOffState menuitem is 0...but the checkmark icon still here!).
>Is there a problem with this class or is it a problem of mine?
What I did in a similar situation (in my Thucydides app) was simply to
implement validateMenuItem. In this way I was able to achieve some pretty
elaborate combinations of enabling and checking. The download includes the
source code if you want to examine it; the one you want is the original,
Panther version ("Thucydides"), not the Tiger "ThucydidesCoreDate" one (in
which I abandoned the search field menu - I think it's a rather poor piece
of interface no matter how you slice it). m.
--
matt neuburg, phd = <email_removed>, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>
| Related mails | Author | Date |
|---|---|---|
| malcom | Jul 19, 19:30 | |
| Adam Knight | Jul 19, 19:37 | |
| malcom | Jul 19, 19:40 | |
| malcom | Jul 19, 21:07 | |
| Matt Neuburg | Jul 19, 21:36 |






Cocoa mail archive

