• 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: Still unable to work out mouse position
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Still unable to work out mouse position


  • Subject: Re: Still unable to work out mouse position
  • From: John Joyce <email@hidden>
  • Date: Sat, 29 Nov 2008 00:10:59 -0600


On Nov 28, 2008, at 11:23 PM, email@hidden wrote:

From: "Christian Graus" <email@hidden>
Subject: Still unable to work out mouse position
To: email@hidden
Message-ID:
	<email@hidden>
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 (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


  • Prev by Date: Co-ordinate conversion question
  • Next by Date: Re: Checking One Array Against Another
  • Previous by thread: Still unable to work out mouse position
  • Next by thread: Co-ordinate conversion question
  • Index(es):
    • Date
    • Thread