SelectTextAreaText - Cursor on the left Side?
BlitzMax Forums/MaxGUI Module/SelectTextAreaText - Cursor on the left Side?
| ||
| Hi there! I have a problem with the SelectTextAreatText command. If i use it, the cursor position will be on the right Selectionside but i want it on the left. How can i realize it? Here is some Code: SuperStrict
Framework BRL.Win32MaxGUI
Import BRL.EventQueue
Import BRL.StandardIO
Local window:TGadget = CreateWindow("Window",320,320,480,480)
Local text:TGadget = CreateTextArea(0,0,window.clientwidth(),window.clientheight(),window)
text.setlayout 1,1,1,1
ActivateGadget text
SetTextAreaText text," Line 1~n Line2~n Line3"
SetGadgetFilter text,FilterKey,text
Repeat
WaitEvent()
Until EventID()=EVENT_WINDOWCLOSE
Function FilterKey:Int(event:TEvent,context:Object)
Local this:TGadget
Local id:Int,key:Int,mods:Int
id=event.id
key=event.data
mods=event.mods
this=TGadget(context)
If id=EVENT_KEYDOWN
If key=KEY_HOME
Local cursorpos:Int = TextAreaCursor(this)
Local pos:Int = TextAreaChar(this,TextAreaLine(this,cursorpos))
Local line:String = TextAreaText(this,TextAreaLine(this,cursorpos),1,TEXTAREA_LINES)
Local sellen:Int = TextAreaSelLen(this)
For Local i:Int=0 Until line.length
If Not IsSpace(line[i])
i:+pos
If i<>cursorpos
If mods=1
SelectTextAreaText this,i,0
SelectTextAreaText this,i,cursorpos-i+sellen
ElseIf mods=0
SelectTextAreaText this,i,0,TEXTAREA_CHARS
Else
Return 1
EndIf
Else
If mods=1
SelectTextAreaText this,pos,0
SelectTextAreaText this,pos,cursorpos-pos+sellen
ElseIf mods=0
SelectTextAreaText this,pos,0,TEXTAREA_CHARS
Else
Return 1
EndIf
EndIf
Exit
EndIf
Next
Return 0
EndIf
EndIf
Return 1
EndFunction
Function IsSpace:Byte(char:Byte)
Return char<=32 And char<>"~n"[0]
EndFunctionNavigate with the cursor is like hell if its on the right selectionside (after you use SHIFT+HOME) while pressing UP and DOWN. Hope for help. Greeze, FOODy --- Sorry for my bad english ;) |