GUI question about cursor position
BlitzMax Forums/BlitzMax Programming/GUI question about cursor position
| ||
I ve been looking at the MaxIDE code source because i'm willing to try my skills at implementing code completion in it cause damn I can't live without autocompletion... However, for some reason, I need to know the x/y position of the cursor when it's placed in the text area where the user writes his code... Here is what I found in the BMaxIDE: Type TOpenCode Extends TToolPanel Field host:TCodePlay Field textarea:TGadget Field dirty=True Field filesrc$,cleansrc$,cleansrcl$ Field current:TDiff Field undolist:TList=New TList Field redolist:TList=New TList Field helpcmd$,helpstring$ Field seek$ Field cursorpos,cursorlen,cursorline what's interesting here is the Field cursorpos, but seeing the rest of the code, it seems to be the position of the cursor in term of caracters... Anybody having an idea how I could use it (or any other method) to get the x and y coordinates of the cursor (and I don't care if it s the coordinates relative to the top left corner of the textarea or the screen or anything else... just give me some x and y :) ) I thought of doing something like getting the string that precedes the cursor, calling the TextWidth procedure on it to know its graphic length, substract the position of the horyzontal navbar of the textarea... this would probably give me the x coordinate, but I was hoping there would be a cleaner solution. thanks!! |
| ||
textwidth() textheight() ?? I think based on cursorpos and cursorline you should be able to figure it out from there. |
| ||
well, so if I know using cursorpos that my cursor is behind the 10th caracter of the 54th line, how do I know what are it's x and y coordinates (without using TextWidth and TextHeight, and without taking into account the fact that the user might well have scrolled the horizontal and vertical sliders)? |