• 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: Is it possible to get mouse click position in Scroll View?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Is it possible to get mouse click position in Scroll View?
      • From: Shane Stanley <email@hidden>
References: 
 >Re: Is it possible to get mouse click position in Scroll View? (From: phil stokes <email@hidden>)
 >Re: Is it possible to get mouse click position in Scroll View? (From: Shane Stanley <email@hidden>)

  • Prev by Date: Re: Is it possible to get mouse click position in Scroll View?
  • Next by Date: Re: Is it possible to get mouse click position in Scroll View?
  • Previous by thread: Re: Is it possible to get mouse click position in Scroll View?
  • Next by thread: Re: Is it possible to get mouse click position in Scroll View?
  • Index(es):
    • Date
    • Thread