MaxGUI: CharFromPos, PosFromChar in Textarea?

BlitzMax Forums/BlitzMax Programming/MaxGUI: CharFromPos, PosFromChar in Textarea?

Perturbatio(Posted 2005) [#1]
Is there any way to get the graphical coords of a character in a textarea, and also to get the character position at a particular x,y coordinate?

i.e. in windows, the Richedit control has EM_CHARFROMPOS and EM_POSFROMCHAR.

I could implement this for win32, but what about the other two platforms?


Perturbatio(Posted 2005) [#2]
*bump*


Tricky(Posted 2005) [#3]
In my J-Text I used this code for that:

	Cl = TextAreaCursor(EWin[CDoc],TextArea_Lines)
	cursorpos=TextAreaCursor(EWin[CDoc],TEXTAREA_CHARS)
	cursorlen=TextAreaSelLen(EWin[CDoc],TEXTAREA_CHARS)
	SetStatusText Window,DocName[CDoc]+"~t~t Line: "+Int(Cl+1)+" Pos:"+Int((CursorPos-Cursorlen-TextAreaChar(EWin[CDoc],CL))+1)+"      "


I guess you already know that EWin[CDoc] is the textarea var I used. You can ignore DocName[CDoc]. J-Text uses that to show the file name of the document that is displayed there.

(I must credit the BMax team. I came up with this code after diggging through the source code of the BMax IDE)