home *** CD-ROM | disk | FTP | other *** search
- Objective:
- To learn to receive event messages from a matrix object and tell
- which element within a matrix is sending a message.
- Terms:
- Tag: an integer associated with an element of a matrix object.
-
- Discussion:
-
- We will use almost the same procedure as we have done before but
- we will use the selectedRow, selectedCol and selectedTag methods
- to get the position of the matrix button that has been selected.
-
- Method:
-
- Create a subclass of "Object" and give it two actions: "myAction:"
- and "myAction2:". Unparse. Then create an instance of it using the
- "Objects/NewCustom Objects" meun selection. Drag a radio button
- on to the screen and use the ALT/DRAG on one of the corners to
- create a matrix of Radio buttons with about 5 rows and three columns.
- Do the same with a button. You will now have a matrix of radio buttons
- and a matrix of regular bottons. Connect the matricies to the myObject1
- by CONTROL/DRAGING a line from the matrix objects to "Objects" window
- and connect it to the myObject1 and use the myAction1: method for one
- matrix and the myAction2: method for the other matrix. Save the
- nib file and change the action methods in MyObject.m to be the following:
-
- - myAction:sender
- {
- printf("Row = %d ", [sender selectedRow]);
- printf("Col = %d ", [sender selectedCol]);
- printf("Tag = %d\n", [sender selectedTag]);
- return self;
- }
-
- - myAction2:sender
- {
- printf("Row = %d ", [sender selectedRow]);
- printf("Col = %d ", [sender selectedCol]);
- printf("Tag = %d\n", [sender selectedTag]);
- return self;
- }
-
- Save ant type "make". Note that by default, the Tag for the radio
- buttons is 0 or 1 for the second radio button only. To have a unique
- tag for each radio button selection use the inspector for the radio button
- matrix and check the box that says "Cell Tags = Positions".
-
- Other Suggestions:
-
- Try changing some of the other options in the matrix inspector.
-
- Summary:
-
- You now know how to integrate a matrix of objects into your programs
- for interfaces that require selecting one of many options.
-
-