Textbox Cursor Position
BlitzMax Forums/MaxGUI Module/Textbox Cursor Position
| ||
I'm trying to apply Regular Expressions to a textbox to limit the available characters, the problem is applying it on the textbox change event puts the blinking cursor at the beginning of the textbox. Is there anyway to set the position of the cursor? Local regex:TRegEx = TRegEx.Create("[^0-9]") Local s:String = regex.ReplaceAll(GadgetText(textbox), "") SetGadgetText(textbox,s) |
| ||
No, not for a TextField, may use a TextArea then (if that is possible). To have the TextField limited to some characters only there is a Filter Function you can use for TextFields, that should be the first choice. |
| ||
Hiya, If you're using windows then I have some Win32 code that will work to select text. I've only used it on Win7 but I'm sure it will work on XP/Vista too. To set just the cursor position you set the Length parameter to 0. Function SelectTextFieldText(TextField:TGadget,Start,Length) ?Win32 SendMessageW(TextField.Query(QUERY_HWND),EM_SETSEL,Start,Start+Length) ? EndFunction Edit:- And a function that will insert text at the cursor position... Function SetTextFieldText(TextField:TGadget,Text$) ?Win32 SendMessageW(TextField.Query(QUERY_HWND),EM_REPLACESEL,True,Int Text.ToWString()) ? EndFunction And a quick 'How To Use' example... Last edited 2012 |