bplus
Full Member
Posts: 127
|
Post by bplus on Feb 19, 2022 23:04:59 GMT -5
I don't understand this. If you are typing stuff in a multi-line textbox and you hit enter, chr$(13), you automatically start a new line.
|
|
|
Post by metro on Feb 20, 2022 3:09:21 GMT -5
I don't understand this. If you are typing stuff in a multi-line textbox and you hit enter, chr$(13), you automatically start a new line.
|
|
|
Post by tsh73 on Feb 20, 2022 3:54:31 GMT -5
I adapted code to multiline textbox Now it on timer checks that needed textbox is active that we indeed pressed Enter gets text from textbox - adds CRLF - prints it back - moves caret postion from 0 to last one (googled, have no idea how it works) So even if you press Enter in the middle of a string it will add new line in the end. (probably could be fixed if comeone has a code for getting caret position in a textbox)
nomainwin WindowWidth = 550 WindowHeight = 410 UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2)
'-----Begin GUI objects code
TexteditorColor$ = "palegray" texteditor #main.log, 275, 27, 255, 320 TexteditorColor$ = "white" ' texteditor #main.texbox3, 5, 27, 255, 320 textbox #main.texbox3, 5, 27, 255, 320 statictext #main.statictext1, "Enter text here", 5, 5, 84, 20 statictext #main.statictext4, "This is log panel", 275, 2, 98, 20
'-----End GUI objects code
open "getting ENTER from a textbox" for window as #main print #main, "font ms_sans_serif 10" print #main, "trapclose [quit.main]" handle2Check = HWND(#main.texbox3) ' #main.log "!disable" timer 100, [tick]
[main.inputLoop] 'wait here for input event wait
[quit.main] 'End the program timer 0 close #main end
[tick] 'is textbox active? lastHandle = handle CallDLL #user32, "GetFocus", handle As long if handle <> handle2Check then wait 'else check if Enter was pressed keycode = 13 CallDLL #user32, "GetAsyncKeyState", keycode As long, _ result As short if lastHandle <> handle then wait 'ignore keypress left from previous control if result<>0 then #main.log "Got Enter pressed" '#main.texbox3 "CR"; #main.texbox3 "!contents? varName$"; #main.texbox3 varName$;chr$(13);chr$(10); 'sets insertion pt at 0, needs LAST res=SendMessage(handle2Check , _EM_SETSEL, 0, -1) res=SendMessage(handle2Check , _EM_SETSEL, -1, -1) END IF wait
Function SendMessage(hWnd, Msg, wParam, lParam) CallDLL #user32, "SendMessageA", hWnd As ulong, _ Msg As long, _ wParam As long, _ lParam As long, _ SendMessage As long End Function
|
|
bplus
Full Member
Posts: 127
|
Post by bplus on Feb 20, 2022 12:21:04 GMT -5
I don't understand this. If you are typing stuff in a multi-line textbox and you hit enter, chr$(13), you automatically start a new line.
Yeah right! sorry I was checking out a TextEditor control. Seems like Ctrl+Enter is a heck of allot easier than trying to force Enter to work in a Textbox, just use TextEditor if you need Enter to work as expected.
|
|