Here is what I'm trying to achieve.
Under submenu 1, there are three options to choose from: Default Action, Action 1, and Action 2. I would like to do something similar to Radio Button functionality, where if one option is selected, the other one is automatically unchecked.
I was wondering if there was any way to execute NSOffState or NSOnState of other IBAction func within other IBAction func. An example would be a menu where the user has to choose between Beginner, Intermediate or Advanced modes when launching a new game.
e.g.
@IBAction func actionOne(sender: NSMenuItem){
if(sender.state == NSOnState){
sender.state = NSOffState
/*turn on Default Action*/
} else {
sender.state = NSOnState
/*turn off Default Action and Action 2*/
/*code for Action 1's settings*/
}
@IBAction func actionTwo(sender: NSMenuItem){
if(sender.state == NSOnState){
sender.state = NSOffState
/*turn on Default Action*/
} else {
sender.state = NSOnState
/*turn off Default Action and Action 1*/
/*code for Action 1's settings*/
}
@IBAction func defaultAction(sender: NSMenuItem){
if(sender.state == NSOnState){
sender.state = NSOffState
/*code for default settings*/
} else {
sender.state = NSOnState
/*turn off Action 1 or Action 2 (whichever one was on)*/
/*code for default settings*/
}
And apparently I can't post any images due to lack of reputation. I'll link it to a dropbox image; https://goo.gl/SGvvcq
Here is a link to the Apple's official page for the description of setState. https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/MenuList/Articles/MenuItemStates.html
"You can use states to implement a group of mutually exclusive menu items, much like a group of radio buttons. For example, a game could have three menu items to show the level of play: Beginner, Intermediate, and Advanced. To implement a such a group, create one action message that they all use. This action message changes the appropriate setting, and then reflects that change by unchecking the currently checked item and checking the newly selected item."