• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: clicking in NSMatrix.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: clicking in NSMatrix.


  • Subject: Re: clicking in NSMatrix.
  • From: Oscar Morales Vivó <email@hidden>
  • Date: Mon, 5 May 2003 23:42:40 +0200

Thanks for your helpful reply... BUT ;)

I know that would work (it's not the first time I fight against NSMatrix. One of my pending subjects). I guess I make a mess of myself and don't explain myself very well. What I really wanted to know was if the sender was always going to be the NSMatrix and if it is officially defined as so. I would have thought it made more sense to have the NSButtonCell as the sender considering it was customized to have a target and action.

Originally I placed the options in a menu, so you could just click on the menus (or their keyboard equivalents) to make a number of elements in the graphics view appear or disappear. I thought it would be nifty to have it too in a floating palette, and there I placed a NSMatrix of checkboxes.

I think I'll do something like the following:

- (IBAction)viewChange:(id)sender
{
switch([sender tag])
{
...
}
}

- (IBAction)matrixViewChange:(id)sender
{
[self viewChange:[sender selectedCell]];
}

Which centralizes the code nicely and doesn't add almost any complexity.

Anyway, pointers to any good tutorials/sample code on advanced uses of NSMatrix would be appreciated.

Thanks for your help:

Oscar Morales.

On Monday, May 5, 2003, at 21:11 Europe/Madrid, email@hidden wrote:


On lundi, mai 5, 2003, at 08:06 PM, Oscar Morales Vivs wrote:

Greetings there. Maybe someone can help me with my NSMatrix troubles.

I have a NSMatrix of checkboxes. I wanted to use the tag of each checkbox to know what to modify when they were clicked, and assigned to each one of the cells' target an action (which is the same for all of them). However, when I run the program, the sender of the action that is performed when I click on one of the checkboxes isn't the button cell, but the NSMatrix, so I can't just use [sender tag] to know what to do (that action can also be called from menu items, so I wanted to avoid type-checking)

Is that a bug of a feature? I figured a matrix cell would send itself as the sender of an action if set to have one, but I might be wrong. And if the NSMatrix is meant to be the sender, it makes for not very elegant code.

Any good advice on how to keep the code the same for menus & checkboxes and avoid having these problems will be greatly > appreciated.

IIRC, the solution is to:
- set the action from the NSMatrix to the target
- in the method:

- (void) someoneClickedOnOneOfMyCheckBoxes:(id) sender
{
int tag;

tag=[[sender selectedCell] tag];

// Do your process here
}


/*
Oscar Morales Vivs

Eternal Computer Science Student. Master of C++ Templates. Cocoa Nut. Computer Graphics Illuminati. UI Guru in Training. Dabbler in all things CS and most which are not.

Web stuff: http://homepage.mac.com/oscarmv/
*/
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: clicking in NSMatrix.
      • From: publiclook <email@hidden>
References: 
 >Re: clicking in NSMatrix. (From: email@hidden)

  • Prev by Date: Cocoa's erasing the contents of my window.
  • Next by Date: Re: Can't modify existing user interface
  • Previous by thread: Re: clicking in NSMatrix.
  • Next by thread: Re: clicking in NSMatrix.
  • Index(es):
    • Date
    • Thread