Re: How to find the position of an NSCell?
Re: How to find the position of an NSCell?
- Subject: Re: How to find the position of an NSCell?
- From: Kai-Mikael Jää-Aro <email@hidden>
- Date: Wed, 11 Jul 2007 17:28:42 +0200
Wagner Truppel kirjoitti 2007-07-04 kello 19:43:
Hi Kai,
an easy way is to sequentially set each cell tag (either through IB
or programmatically), starting from 0. Then, given a tag, you know
the cell's row and column in the matrix, as follows: if your matrix
has C columns, then the row and column of a cell with a given tag are:
row = tag / C
col = tag % C
(tag, row, and col all start at 0)
Right, that's what I figured too. Actually I stored the x and y of
the cell at creation so I didn't have to redo it for each access.
Now for my next trick, can I do the same thing in a toolbar? I'm a
bit uncertain whether NSToolbar will insert space between elements
and how large that space may be.
Hope this helps.
Wagner
Subject: How to find the position of an NSCell?
From: Kai-Mikael Jää-Aro <email@hidden>
Date: Wed, 4 Jul 2007 13:51:19 +0200
I am constructing a hierarchical tool palette and thought the best
way to do this would be through using a (subclass of) NSPanel
containing an NSMatrix with NSButtonCell objects.
Now, when the user presses one of the NSButtonCells I want to open
a new NSPanel with the sub-choices for that button right below the
pressed button but I believe that in order to position the NSPanel
I will have to know the position of the button and I can't figure
out any better method for finding that position than letting the
button have a back reference to its containing view and its
position in that view and then ask the view for the screen
coordinates when needed.
Or, is there a more direct method?
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden