Re: NSMatrix actions
Re: NSMatrix actions
- Subject: Re: NSMatrix actions
- From: Robert Goldsmith <email@hidden>
- Date: Thu, 11 Oct 2001 10:12:30 +0100
In InterfaceBuilder you can define any class with any outlets and any
actions. Tell InterfaceBuilder that you have a subclass of NSView or
whatever and what actions it has. You can event get InterfaceBuilder to
parse an existing class interface if you have written it already. You can
also add arbitrary actions to the set understood by the firstResponder place
holder. Once you have told InterfaceBuilder what actions your target
understanbds then you can drag a connection to the target and select an
action or you can drag a connection to firstResponder and select one of its
actions.
I am fully aware of the target/action concept and am quite capable of
using IB for normal stuff. The very point of my original post was
that, it seems, I CANNOT simply drag connections to the subclass of
NSMatrix - here's why:
I need an NSMatrix with a scrollView that has a variable number of
instances of my subclass of NSCell. Last I checked, you could not
create NSCell subclasses like you could NSViews so the subclass
drawing routines are coded by hand. Further, even if I instantiated
this subclass in IB, I could not simply drag it out to a matrix for
two reasons: 1) I want a variable number of cells and 2) IB won't let
u do that with custom cells (anything not in it's palettes - and some
that are).
Therefore, I have done the following:
Create a 'CustomView' and set it's type to NSMatrix then give it a
scrollbar, link it to an outlet in my controller class and setup what
I can in IB.
Now, in code, I have subclassed NSCell and, in the awakeFromNib
method of my controller class, tell the NSMatrix what NSCell subclass
it will be using and how many to setup initially. This number can
change.
What I need to do is get NSMatrix to send to the relevant instance of
the NSCell subclass an action (ie call the action method of the
instance) when the instance is single clicked (and others for double
click or drag etc.).
I understand how to to set NSMatrix to send an action to the correct
NSCell subclass instance but, like with any other message, you can't
just tell it the instance, it needs to know the action to perform as
well. What I want to know is what action is generated by NSMatrix
when the use single-clicks on a cell in the matrix?
Once I know this I can write the code in the NSCell subclass that
deals with it and, when the action is triggered, NSMatrix will find
that my class can handle the action and send it to me instead of not
sending it or sending it somewhere else.
So, when you click on a cell in an NSMatrix, what action is sent?
There is no single action that all users of NSMatrix want to send. That is
why NSMatrix like all NSControls lets you set any action.
Ok, then, instead of the above question how about:
How do I tell NSMatrix that, when a user clicks (not double clicks,
drags, copies, pastes or deletes - just single clicks) a cell, it
should send action 'x'.
or is there only one action 'receiver' that has to actively decode
every action sent to work out which one was sent?
Robert
--
Please note the new email address:
email@hidden