MaxGUI: SelectTextAreaText Cursorausrichtung
Übersicht

![]() |
FOODyBetreff: MaxGUI: SelectTextAreaText Cursorausrichtung |
![]() Antworten mit Zitat ![]() |
---|---|---|
Hi, Community.
Wollt Fragen ob es eine einfache möglichkeit gebe bei dem SelectTextAreaText Befehl den Cursor nicht nach Rechts sondern nach Links ausrichten zu lassen. Gibst da einen Trick? Den wenn ich jetzt mit SHIFT+HOME einen Text selektiere kann ich nicht mehr richtig mit dem Cursor navigieren da er auf der "falschen" Seite ist. Ich hoffe ihr könnt mir helfen. Der Code wäre in voller Kürze hier: Code: [AUSKLAPPEN] 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) For Local i:Int=0 Until line.length If Not IsSpace(line[i]) If i+pos<>cursorpos If mods=1 SelectTextAreaText this,pos+i,cursorpos-(pos+i)+TextAreaSelLen(this) ElseIf mods=0 SelectTextAreaText this,pos+i,0,TEXTAREA_CHARS Else Return 1 EndIf Else If mods=1 SelectTextAreaText this,pos,cursorpos-pos+TextAreaSelLen(this) 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] EndFunction Ich hoffe ihr hab versteht mein Problem ![]() Gruß, FOODy |
||
BlitzMax + MaxGUI, 64-bit Arch Linux: Intel Core² E8500 | 8 GB Ram | GeForce GTX 460 · 1024 MB |
klepto2 |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Also wenn ich dich richtig verstanden habe, dann willst du das angenommen du drückst eine Pfeiltaste, der Cursor dort ist wo der die Selektion angefangen hat und nicht wie es aktuell ist, das der Cursor am Selektions ende ist, oder?
Wenn ja, dann errechne doch (so wie jetzt) den zu selektierenden Bereich, nur diesmal unter der berücksichtigung, das ganze nicht von links nach rechts zu selektieren, sondern von rechts nach links. Ich hoffe das funktioniert: Code: [AUSKLAPPEN] 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) For Local i:Int=0 Until line.length If Not IsSpace(line[i]) If i+pos<>cursorpos If mods=1 SelectTextAreaText this,pos+i+cursorpos-(pos+i)+TextAreaSelLen(this),-(cursorpos-(pos+i)+TextAreaSelLen(this)) ElseIf mods=0 SelectTextAreaText this,pos+i,0,TEXTAREA_CHARS Else Return 1 EndIf Else If mods=1 SelectTextAreaText this,pos+cursorpos-pos+TextAreaSelLen(this),-(cursorpos-pos+TextAreaSelLen(this)) 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] EndFunction |
||
Matrix Screensaver
Console Modul für BlitzMax KLPacker Modul für BlitzMax HomePage : http://www.brsoftware.de.vu |
![]() |
FOODy |
![]() Antworten mit Zitat ![]() |
---|---|---|
So hab ich es zuerst auch gedacht, klepto2.
Das Problem ist nur das MaxGUI bei einem wert von <0 alles nach pos Selektiert :/ Aber verstanden hast du mich schon richtig ![]() Gruß, FOODy |
||
BlitzMax + MaxGUI, 64-bit Arch Linux: Intel Core² E8500 | 8 GB Ram | GeForce GTX 460 · 1024 MB |
Dreamora |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Das ist Sinn und Zweck von -1. "Select from here to end"
Wenn du rückwärts selektieren willst, beweg den Cursor zurück und selektier vorwärts ... |
||
Ihr findet die aktuellen Projekte unter Gayasoft und könnt mich unter @gayasoft auf Twitter erreichen. |
![]() |
FOODy |
![]() Antworten mit Zitat ![]() |
---|---|---|
@Dreamora:
Hatte es auch schon versucht. Entweder falsch oder es geht nicht. Code: [AUSKLAPPEN] 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]) If i+pos<>cursorpos If mods=1 SelectTextAreaText this,pos+i,1 SelectTextAreaText this,pos+i,cursorpos-(pos+i)+sellen ElseIf mods=0 SelectTextAreaText this,pos+i,0,TEXTAREA_CHARS Else Return 1 EndIf Else If mods=1 SelectTextAreaText this,pos,1 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] EndFunction Die MaxGUI ist echt fürn arsch was das ansteuern von Gadgets angeht... Gruß, FOODy |
||
BlitzMax + MaxGUI, 64-bit Arch Linux: Intel Core² E8500 | 8 GB Ram | GeForce GTX 460 · 1024 MB |
Übersicht


Powered by phpBB © 2001 - 2006, phpBB Group