• 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: Shane Stanley <email@hidden>
  • Date: Fri, 01 Apr 2016 22:17:18 +1100

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


  • Follow-Ups:
    • Re: Is it possible to get mouse click position in Scroll View?
      • From: Shane Stanley <email@hidden>
    • Re: Is it possible to get mouse click position in Scroll View?
      • From: Phil Stokes <email@hidden>
References: 
 >Re: Is it possible to get mouse click position in Scroll View? (From: phil stokes <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