|
Post by honkytonk on Nov 18, 2022 0:45:06 GMT
Hello, I know this topic has been covered before, but I couldn't find it, it was a long time ago. I'm looking for the ASC codes of the "Enter" key. And if possible a read procedure (inkey$ = ??). thank you for
|
|
|
Post by plus on Nov 18, 2022 1:56:14 GMT
13 Enter
do k$ = input$(1) 'go ahead and try Enter loop until len(k$) print asc(k$)
|
|
|
Post by tsh73 on Nov 18, 2022 7:04:01 GMT
inkey$ works only in graphicbox / graphic window but in dialog window one could have button with ".default" extension, which will work on Enter in a textbox.
|
|
|
Post by honkytonk on Nov 18, 2022 8:55:08 GMT
I will make a 3 x 3 graphicbox that I will put in a corner. I remember it takes two codes (Google say: "10 13" ??), but I don't know how to formulate the test: if inkey$ = ?
|
|
|
Post by tsh73 on Nov 18, 2022 9:58:05 GMT
it will work only while this graphicbox has focus The moment you switch to textbox/button/whatever, graphicbox will stop getting keyboard events.
And it looks like in dialog window it does not work at all.
after opening window, set handler
'set characterInput handler print #main.graphicbox5,"when characterInput [key]"
Somewhere else
[key] notice "Got key ";asc(Inkey$);" ";asc(mid$(Inkey$,2)) if Inkey$=chr$(13) then notice "Got Enter" wait
|
|
|
Post by honkytonk on Nov 18, 2022 13:00:30 GMT
Thanks a lot, I save your information. So what I wanted to do is not possible, because at: "key" the focus will either be in a textbox or in a texteditor. There are essential buttons.
|
|
|
Post by tsh73 on Nov 18, 2022 14:00:06 GMT
in this case, default button will work (it could be put off-screen and it will still intercept Enter key)
Only thing is that is works only for windows of type Dialog.
|
|
|
Post by honkytonk on Nov 18, 2022 15:33:50 GMT
I don't understand if a button is off-screen, it cannot be accessed. What is the: "default button"?
Edit: My window is "window_nf"
|
|
|
Post by tsh73 on Nov 18, 2022 16:26:50 GMT
From a help file on Button:
It will trigger then you press Enter in a textbox/texteditor You don't have to actually click on it so it will work even offscreen.
But it works only in dialog windows. Try - will your program work with window type "dialog"?
From thre help file on Window types
|
|
|
Post by honkytonk on Nov 18, 2022 17:27:35 GMT
My window is a "window_nf", with textboxes, buttons, statictext and a texteditor. In addition, the "dialog" always opens in the middle of the screen and must be moved manually. "dialog" is bad for me
|
|
|
Post by Rod on Nov 18, 2022 19:45:46 GMT
I hate guessing what is wrong and what is required. Can we break the code down to a simple example of what is wrong and what you need with say one window and one textbook and or one button.
|
|
|
Post by xxgeek on Nov 18, 2022 22:51:58 GMT
If I'm reading this correctly you need a way to grab the text in the text window, and then move on in your code, but can't use [enter] because the type of window you are using doesn't allow a "default" button like a dialog window does.
Had the same problem while working on the search engine for JB the other day. I didn't want a dialog window either.
If I'm wrong about your problem, this may help someone else some day. This is just an example that runs ok in JB. You will need to edit to get exactly what you want, (if I'm correct that is)
Run this code in JB. It opens a window with a textbox, and gives the textbox focus. Just start typing. When you're done use a period . at the end and it will goto to the correct label. If you type Hope. it will print Hi Mom Happy Birthday If you type anything but Hope . it will type Hi Vlad, Love your Honesty.
Don't forget - type a period after your word without a space.
Other than a that you need script (VB), CMD (batch) or Powershell to hit [enter] for you. Or some other 3rd party tool.
Hope this helps.
'this is test code to show an example 'type Hope then a period - then type anything but Hope and see the difference 'Your code doesn't need to loop if you don't want to. 'Remove the goto lines and it only prints once and waits, use this to get done what YOU need to get done.
'Don't forget - type your word, then a period . (You can change the period in the code to whatever suits you)
WindowWidth = 228 : WindowHeight = 514 UpperLeftX= 1 : UpperLeftY=1 textbox #main.text, 60,100,100,25 open "test" for window as #main #main "trapclose [quit]" #main.text "!setfocus"
MySpecialWord$ = "Hope" [doAgain] #main.text "!setfocus" #main.text "" while x = 0 scan #main.text "!contents? a$" if right$(a$, 1) = "." then exit while wend
#main.text "!contents? a$" a$ = left$(a$, len(a$) -1) if a$ = MySpecialWord$ then [doWhateverYouWant] else [dontDoWhateverYouWant] wait
[quit] close #main end
[dontDoWhateverYouWant] print "Hi Vlad, Love your honesty" goto [doAgain] wait
[doWhateverYouWant] print "Hi MOM, Happy Birthday!" wait
[/code/
|
|
|
Post by tsh73 on Nov 19, 2022 8:46:45 GMT
Well, there is known workaround to place dialog window: you just open small ordinary window at the dialog corner place and after that open dialog (don't forget to close it).
Also good thing is that default button works even hidden.
Bad but circumventable thing is that dialog window closes on ESC (I made it closing only on Close button - but this prevents close from [X] button top right corner)
But the thing that probably could not be helped is that texteditor in dialog window is unusable - any cursor key press changes to other control and there is no way to insert a new line (I kind of made if via Paste from clipboard, but to use it reliably you need special hidden texteditor)
' dialog and default button test nomainwin
'to position dialog window, we open helper window first 'don't forget to close it with dialog! UpperLeft=200 UpperLeftX=100 WindowWidth = 10 WindowHeight = 10 open "position window" for window_nf as #helperWindow
WindowWidth = 550 WindowHeight = 410 'centring code, by FreeForm - comment out 'UpperLeftX=int((DisplayWidth-WindowWidth)/2) 'UpperLeftY=int((DisplayHeight-WindowHeight)/2)
textbox #main.textbox1, 22, 16, 100, 25 textbox #main.textbox2, 22, 51, 100, 25 texteditor #main.texteditor3, 22, 131, 152, 200 button #main.button1, "Button1", [button1Click], UL, 142, 16, 122, 25 button #main.default, "default", [defaultBtnClick], UL, 182, 126, 104, 25 statictext #main.statictext6, "log", 294, 21, 144, 20 texteditor #main.log, 294, 41, 224, 255 button #main.button2, "Button2", [button2Click], UL, 142, 51, 122, 25 button #main.button3, "Button3", [button3Click], UL, 142, 86, 122, 25 textbox #main.textbox10, 22, 86, 100, 25 button #main.btnClose, "Close", [ClosBtnClick], UL, 446, 326, 88, 20 checkbox #main.checkbox12, "hide", [checkbox12Set], [checkbox12Reset], 182, 156, 128, 20 button #main.NL, "newLine", [newLineBtnClick], UL, 182, 186, 104, 25 '*** menus are not supported in windows of type dialog *** menu #main, "Edit" '<--- Texteditor Menu can be moved but not removed.
open "dilag + default button" for dialog as #main print #main, "trapclose [quit.main]"
print #main, "font ms_sans_serif 10" #main.log "!disable" 'read only '#main.default "!hide" 'Nice! works hidden! 'put a new line to a clipboard for NewLinwe button to work '(until you change clipboard that is) #main.texteditor3 "" 'new line #main.texteditor3 , "!selectall" #main.texteditor3 , "!copy"
wait
[quit.main] 'because pressing ESC closes dialog window, we prevent it if not(closeBtnClicked) then notice "please use Close button" wait end if Close #main Close #helperWindow END
[button1Click] 'Perform action for the button named 'button1' #main.log, time$();" Button 1 clicked" wait
[defaultBtnClick] 'Perform action for the button named 'default' #main.log, time$();" default Button triggered" wait
[button2Click] 'Perform action for the button named 'button2' #main.log, time$();" Button 2 clicked" wait
[button3Click] 'Perform action for the button named 'button3' #main.log, time$();" Button 3 clicked" wait
[ClosBtnClick] 'Perform action for the button named 'btnClose' closeBtnClicked=1 goto [quit.main] wait
[checkbox12Set] 'Perform action for the checkbox named 'checkbox12' #main.default "!hide" wait
[checkbox12Reset] 'Perform reset for the checkbox named 'checkbox12' #main.default "!show" wait
[newLineBtnClick] '#main.texteditor3 ">";chr$(13);"<" #main.texteditor3 "!setfocus" #main.texteditor3 "!paste" wait
|
|
|
Post by honkytonk on Nov 19, 2022 9:49:15 GMT
@: Rod: The program is here--->: libertybasic.fr/forum/topic-652+post-it.phpThe goal is to add the key: "Enter" to the "Créer" button. The general purpose of the software is a post it "alway on top" which gives access to note-taking files (for a poker player). - Click in the list: calls the file in the text editor. - Check-in at closings. - If modified text editor: save if click on other name. Note: I had big problems with closure conflicts. Not sure if all are solved. @! tsh73: Your solution works very well, I will try to put it in my code. Thank you véry much.
|
|
|
Post by honkytonk on Nov 19, 2022 13:17:14 GMT
Follow: I see a problem when instinctively clicking "Enter" to write a new line, and that can't be protected (as trapclose). I clicked and clicked again and clicked again on the closing cross. 'Chase the habit, it comes back at a gallop'. I hesitate to include your excellent solution, which I treasure in my HD. Thanks again.
|
|