Re: Is it possible to get mouse click position in Scroll View?
Re: Is it possible to get mouse click position in Scroll View?
- Subject: Re: Is it possible to get mouse click position in Scroll View?
- From: Phil Stokes <email@hidden>
- Date: Fri, 01 Apr 2016 19:44:14 +0700
Yeah, I briefly mentioned that as my 3rd option, but is it reliable?
What if the mouse position is on the border between two lines or on the border between one glyph and another?
I don’t know, I’m guessing you’ve done it since you can rattle of the required methods, but it still strikes me as a hell of a lot less code, less points of failure and surely less of a headache to either use an attributed string as Ron suggested or embed an subclass of NSButton as I mentioned.
Best
Phil
> On 1 Apr 2016, at 18:17, Shane Stanley <email@hidden> wrote:
>
> On 1 Apr 2016, at 9:50 PM, phil stokes <email@hidden> wrote:
>>
>> I’d be surprised if you could ever reliably associate the mouse position with the text underneath it
>
> If it's a text view, you can. You need to subclass the text view and override mouseDown:. You get the passed event's loctionInWindow, use convertPoint:FromView: to get the location in the text view, then tell the view's layout manager to return glyphIndexForPoint:inTextContainer:. You then call characterIndexForGlyphAtIndex: to convert from a glyph index to a char index, and from there you can work out the line number. Not simple, but not brain surgery either.
>
> --
> Shane Stanley <email@hidden>
> <www.macosxautomation.com/applescript/apps/>
>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> applescriptobjc-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
applescriptobjc-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden