objective c - Prohibit multiple selection of NSMenuItems by cocoa binding -


i have multiple nsmenuitems in nsmenu. want making 1 of them being on state @ same time. (just single selection list box.)

the first option implement target/action methods them , write code so. if possible want use cocoa binding this.

here want do.

i have single variable can set 3 different values (0,1,2). number corresponds menu items(nsmenuitem0, nsmenuitem1, nsmenuitem2). 1 of nsmenuitems here must on state, , others must off state.

so initial state, nsmenuitem0 on, nsmenuitem1 , nsmenuitem2 off , variable 0. , if user clicks nsmenuitem1, nsmenuitem0, nsmenuitem2 turn off state , variable set 1.

when variable set 2 programatically, nsmenuitem2 should have check, , others shouldn't.

i tried create 3 properties corresponds each item's value bind, , tried customise setter method didn't work because when user clicks menu item on state, check turned off. (i want keep check if user clicks item on state.)

the setter method wrote this.

- (void)setitem0:(bool)b{     if( _item0 ){         // on state, don't want change state.         // doesn't affect ui.         // internal variable no nsmenuitem has check.     }else{         // set other items no here ... (omit code)         // , change property.         _item0 = enable;      } } 

i don't know if approach totally wrong can't think of way achieve this. there way this?


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -