dkl
Full Member
Posts: 234
|
Post by dkl on Dec 7, 2021 5:43:34 GMT -5
As I understand it, when using a textbox one types in a string of characters and hit an 'OK' button to go to a routine to read/get the input It appears when using inkey$ one can only use this command when opening graphics environment and not an 'ordinary' window environment. So how does one get a programme to recognise single character input instantly? I've seen plenty of demos/examples of single character input, but they all use a graphics window.If you change to an 'ordinary' window the code doesn't work. If I change my window to a grapjics window, I lose all my listboxes/textboxes etc.
A nudge in the right direction would help, please
|
|
|
Post by tsh73 on Dec 7, 2021 5:54:45 GMT -5
It really depends on what you really need. Look at this.
'reading textbox content on timer nomainwin
WindowWidth = 160 WindowHeight = 195
UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2)
statictext #main.statictext1, "Type text here", 26, 16, 144, 20 textbox #main.textbox1, 22, 46, 100, 25 statictext #main.statictext3, "Watch it getting there", 22, 86, 144, 20 textbox #main.textbox2, 22, 111, 100, 25 open "untitled" for window as #main print #main, "trapclose [quit.main]"
print #main, "font ms_sans_serif 10"
timer 100, [tick]
wait
[quit.main] Close #main END
[tick]'get text from textbox1, print it to textbox2 old$=var$ #main.textbox1 "!contents? var$" if old$<>var$ then 'without this check you cannot type in lower box #main.textbox2 var$ end if wait
|
|
|
Post by Rod on Dec 7, 2021 8:54:54 GMT -5
When you discuss character input and express a desire for instant character recognition you are really describing a button or range of buttons. An onscreen button has been found to be more user friendly than the old "Key in your choice A=xyz B=rtz So just think button, the buttons can change , can appear and reappear. The great benefit is that the button usually evidences what it does and the user does not need provided with prompts or lists.
|
|
|
Post by Walt Decker on Dec 7, 2021 9:11:15 GMT -5
If you are looking for one particular key stroke you can use timer SomeMillisecs, Branch. In branch you could use either User32.dll function GetKeyState or GetAsyncKeyState with the virtual key code and maks out the pressed, unpressed bit to determine if that key was pressed.
|
|
dkl
Full Member
Posts: 234
|
Post by dkl on Dec 8, 2021 17:38:15 GMT -5
Thank you, Gentlemen for your help and input (excuse the pun!) I simply want to add keyboard input as an option to the word puzzle game (and learn how it's done) Rod, I understand what you are saying and as you can see I have done what you suggested within the word puzzle game. Walt, I always read your posts and your alternative method ideas are always worth noting, but above my programming skills. I'm going to have to look further into your ideas as, I know you like to work directly with dll's and API's and I'm still trying to get my head around some of the BASIC routines etc. I have dowloaded all your info about "What you don't want to know........" and hope to learn from that:) tsh73, I looked at your programme and understand what its doing. I have to say I would never have thought of an idea like that , but after a bit of fiddling I find it works really well and I can filter out unwanted characters BEFORE they get input to the correct textbox. I have attached code of what I want to be able to do, which is to input the letter choice through the keyboard, but also disable the relevant letter button (so it cannot be used again during the word input) 1. Click 'SHUFFLE' to start the programme and shuffle/display the letters. 2. Just input letters from the keyboard (all letters will appear as uppercase) You will see that the letter is input to the textbox and the relevant 'scrabble' tile is 'disabled', which is what I want to achieve and have already implemented this into the main game when using the mouse for input - it works well. Now I have to translate this to the word game - fingers crossed!
|
|