Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Mac > Mac Programmer Help > Multiple choice...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 4 Topic 3702 of 3812
Post > Topic >>

Multiple choice NSPopupButton ?

by slashlos <slashlos@[EMAIL PROTECTED] > Apr 11, 2008 at 08:58 PM

I've decided (hopefully well received) on using a popup button as a 
multiple selection control. I use the item's tag values as a bit 
position whose mask I keep in index 0; a user selecting this item clears 
the entire mask while other item selections toggle that item 'tag' bit.

It's done like this action:

- (void)processPopup:(id)sender
{
   unsigned long value;
   int i, tag = [[sender selectedItem] tag];

   if (![sender indexOfSelectedItem])
   {
     for (i=1; i<[sender numberOfItems]; i++)
     {
       [[sender itemAtIndex:i] setState:NSOffState];
     }
     [[sender itemAtIndex:0] setTag:(value=0)];
     tag = 0;
   }
   else
   {
     BOOL state = [[sender selectedItem] state];

     // tag at index 0 keeps our mask
     value = [[sender itemAtIndex:0] tag];
     [[sender selectedItem] setState:state];
     if (state)
       value |= 1<<tag;
     else
       value ^= 1<<tag;

     [[sender itemAtIndex:0] setTag:value];
   }

   // Tooltip has our name
   NSLog(@[EMAIL PROTECTED]
"%@[EMAIL PROTECTED]
(%09x) = '%@[EMAIL PROTECTED]
' %d:%d",
     [sender toolTip], value,
     [[sender selectedItem] title], tag,
     [[sender selectedItem] state]);
}


But the question is how can I get the visual to mimic the model? Do I 
need to sub-class the popup button so I can have multiple selections?
-- 
/los "I was a teenage net-random"
 




 4 Posts in Topic:
Multiple choice NSPopupButton ?
slashlos <slashlos@[EM  2008-04-11 20:58:26 
Re: Multiple choice NSPopupButton ?
Gregory Weston <uce@[E  2008-04-12 11:12:33 
Re: Multiple choice NSPopupButton ?
slashlos <slashlos@[EM  2008-04-12 10:22:31 
Re: Multiple choice NSPopupButton ?
slashlos <slashlos@[EM  2008-04-20 09:39:26 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Jul 24 2:32:04 CDT 2008.