Good morning!
I would like to be able to find the X,Y location of the insertion point in a text area, the coordinates where youre actually typing. I need to be able to popup some menus depending on what youre doing and would like them to be positioned usefully under where you are actually typing.
At the moment Im doing a serious amount of stupid by figuring out the line number of the text that the insertion point is in via LineNumAtCharPos( ScriptField.SelStart), then adding in the scroll position and multiplying by the textHeight of the font that I got from a separate picture graphics object set to the same font and style and size. Then walking forward through the line until the InsertionPosAtXY returns a number greater or equal to the selstart. Then add in the toolbar offsets and window margins and all the rest.
That is just a horrible hack, but its the best I could figure out and it sort of almost works most of the time. I feel like I should be able to do the opposite and have a XYAtInsertionPoint or some other way to get the relative local coordinates based on the selstart value.
This will only ever run on a Mac. I am not afraid of declares or plugins. I have gone through the NSTextFieldMBS and all its parent classes and I feel like the information is in there somewhere but Im evidently not as versed on the lower level Apple cocoa philosophy as I wished. Any suggestions as to where to go to look or read up would be greatly appreciated. Thank you!