On Nov 28, 2008, at 11:23 PM, [EMAIL PROTECTED] wrote:

From: "Christian Graus" <[EMAIL PROTECTED]>
Subject: Still unable to work out mouse position
To: cocoa-dev@lists.apple.com
Message-ID:
        <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=ISO-8859-1

Thanks to the person who answered yesterday, but I am no closer to a
solution. I have an NSTableView, and it contains NSTextAttachmentCell rows. There's only one column in the table view. Basically, when a user clicks
on a row, I am getting the shouldSelectRow event, which gives me a row
index. I need to know if the user clicked on the icon which is in the first
16 pixels of the row.  To do this, I want to either find out the mouse
position in general then normalise it to the control, or I want to capture mouse movement ( without any clicks ) and record it as I go, so I know when I click, what part of the cell was clicked on. I have found there's an event on a cell that would tell me the mouse position on a click, but I can't work out how to get the event, do I need to subclass NSTextAttachment and NSTextAttachmentCell to make my cell a new type that also tracks the
mouse ? I get that impression from my reading, but surely I can just
subscribe to an event ? If I could just ask for the mouse position on
screen, and normalise it to my table view, that would solve all my issues.
Thanks

christian

Christian, you might consider just adding a column that contains NSButtonCell for each row. With this , it will be a LOT easier to know that what you want users to click on was clicked on. This way, all you need to do is work on the appearance and not invent any wheels. (just put new hubcaps on the wheels) If all you need to know is if a button is clicked, use a button. In IB, drag and drop your image on the buttoncell and you're done, other than setting up notifications, actions or delegation. If you really, really need a button of a specific shape and hitmask, subclass NSButtonCell. (for this you'll want to read up on NSControl and NSButton and test subclassing those first)

You don't need horizontal lines on the NSTableView, because you seem to want the rows to be seamless.

You can still track the mouse location within any NSRect (within a cell's rect relative to the column's rect) but you're going to have to also keep track of the visible area if the view is resized and scrollable.

Depending on what you're trying to do, and if you feel like bothering with it, you may also want to consider NSMatrix, but it's a PITA.
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to