ModuleMenuNode.h
This object stores menu information to be passed to Resound from modules. Future versions will eliminate this node (I hope), when IB is able to generate menus without an application (or I learn to).
The Module Menu Node is a tree node. The root (top) node of the tree should be set with a blank name. This node contains all the menu items to be added directly to Resound's Modules menu . Children nodes have names, and the menu items they contain are for custom submenus off of the Modules Menu.
Let's say you want to make two menu options in the Modules menu. One is just a standard menu option, called "Tweak". The other displays a submenu, called "Twist", with submenu items "Bend", "Break", and "Bust". You'd generate a tree like this:
(Root Node)
Name "" (empty string)
Receiver NULL (indicates this node has submenus)
Message (not set)
Length 2 (for Tweak and Twist)
Submenu[0] points to the node Tweak
Submenu[1] points to the node Twist
Tweak
Name "Tweak"
Receiver object that will receive the Tweak message
Message selector of message sent to Tweak's receiver
Length 0
Submenu... (not set)
Twist
Name "Twist"
Receiver NULL (indicates this node has submenus)
Message (not set)
Length 3 (for Bend, Break, and Bust)
Submenu[0] points to the node Bend
Submenu[1] points to the node Break
Submenu[2] points to the node Bust
Bend
Name "Bend"
Receiver object that will receive the Bend message
Message selector of message sent to Bend's receiver
Length 0
Submenu... (not set)
Break
Name "Break"
Receiver object that will receive the Break message
Message selector of message sent to Break's receiver
Length 0
Submenu... (not set)
Bust
Name "Bust"
Receiver object that will receive the Bust message
Message selector of message sent to Bust's receiver
Length 0
Submenu... (not set)
To do this, you might write write the init method of your module to look like:
- init
{
id returnVal=[super init];
// ABSOLUTELY CALL [super init] FIRST!!!
ModuleMenuNode* tweak=
[[ModuleMenuNode alloc] init];
ModuleMenuNode* twist=
[[ModuleMenuNode alloc] init];
ModuleMenuNode* bend=
[[ModuleMenuNode alloc] init];
ModuleMenuNode* break=
[[ModuleMenuNode alloc] init];
ModuleMenuNode* bust=
[[ModuleMenuNode alloc] init];
[TheModuleMenuNode setReceiver:NULL];
[TheModuleMenuNode setLength:2];
[TheModuleMenuNode setSubmenu: 0 : tweak];
[TheModuleMenuNode setSubmenu: 1 : twist];
[tweak setName: "Tweak"];
[tweak setReceiver: self];
[tweak setMessage:@selector(tweakMe:)];
[tweak setLength:0];
[twist setReceiver:NULL];
[twist setLength:3];
[twist setSubmenu: 0 : bend];
[twist setSubmenu: 1 : break];
[twist setSubmenu: 2 : bust];
[bend setName: "Bend"];
[bend setReceiver: self];
[bend setMessage:@selector(bendMe:)];
[bend setLength:0];
[break setName: "Break"];
[break setReceiver: self];
[break setMessage:@selector(breakMe:)];
[break setLength:0];
[bust setName: "Bust"];
[bust setReceiver: self];
[bust setMessage:@selector(bustMe:)];
[bust setLength:0];
return returnVal;
}
As a result, Resound would create menus in its Modules menu as such:
Resound attaches the appropriate receiver to as the target of Tweak, Bend, Break, and Bust, and sets them to call the appropriate message. In the example above, the receivers of all menus have been set to your own module, and the modules will call, respectively, tweakMe:, bendMe:, breakMe:, or bustMe:.
You don't need to free the nodes--that's taken care of for you by Module's free method.