[comp.sys.next] problem with Interface Builder Action Messasges

mark@apple3.cis.ohio-state.edu (Mark Jansen) (08/02/89)

I am trying to use interface builder for a medium size programming project
and am having trouble with action messages and tags.  I have create a couple of
control panels with buttons and text fields enclosed within matracies and 
boxes.  I have connected the button and text field action messages to target 
my application object and that all works fine. 

I then query the sender of the message for its tag and am getting the 
wrong tag number.  Apparently the tag is from the matrix or box that contains
the button pressed.  How do I get around this difficulty?

-=-
Mark Jansen, Department of Computer and Information Science
The Ohio State University; 2036 Neil Ave., Columbus, OH USA 43210-1277
mark@cis.ohio-state.edu

stone@grumpy.cs.unm.edu (Andrew Stone) (08/02/89)

In article <56535@tut.cis.ohio-state.edu> mark@apple3.cis.ohio-state.edu (Mark Jansen) writes:
>I am trying to use interface builder for a medium size programming project
>and am having trouble with action messages and tags.  I have create a couple of
>control panels with buttons and text fields enclosed within matracies and 
>boxes.  I have connected the button and text field action messages to target 
>my application object and that all works fine. 
>
>I then query the sender of the message for its tag and am getting the 
>wrong tag number.  Apparently the tag is from the matrix or box that contains
>the button pressed.  How do I get around this difficulty?

  When a you have a matrix of buttons [or menuCells for that matter], the
  sender is the matrix itself, not the individual button. To get its tag, 
  you could :
	  myTag = [[sender selectedCell] tag];

Or you could look at its position, and base your logic on #defines,
remembering that 0 is the first position, then:

    int row = [sender selectedRow];   // columnar list
    switch (row) {
      ....

One day I woke up and it all made perfect sense.

andrew

ali@polya.Stanford.EDU (Ali T. Ozer) (08/02/89)

In article <56535@tut.cis.ohio-state.edu> Mark Jansen writes:
>I then query the sender of the message for its tag and am getting the 
>wrong tag number.  Apparently the tag is from the matrix or box that contains
>the button pressed.

If the whole matrix is connected to the target, then "tag" will indeed
refer to the matrix's tag. You can use the "selectedTag" method (which is
simply a short-cut for sending "tag" to the "selectedCell") to get the
tag of the button that was actually pressed.

Ali Ozer, NeXT Developer Support
aozer@NeXT.com