Author Topic: Menu selection and INPUT  (Read 1598 times)

Offline Julian

  • Mc. Print
  • *
  • Posts: 23
    • View Profile
Menu selection and INPUT
« on: 2012-Sep-09 »
Ok I know the title is bad but I can't think of anything better. I have the following situation:
I have a Menu with several options. You select one with the arrow keys and confirm with return (Key 28).
The problem is after one selection in the menu you directly have to enter some information (INPUT). Now the problem is that the INPUT is always 0 because I use the return key in the Menu. I tried something like this in the Menu
Code: (glbasic) [Select]
IF KEY(28)
SELECT windowselection
[...]
ENDSELECT
WHILE KEY(28)
SLEEP 1
WEND
ENDIF
And in the actual window where the input happens:
Code: (glbasic) [Select]
WHILE KEY(28)
SLEEP 1
WEND
INPUT myvar,0,0,TRUE
But this does not work. The only thing that works is doing a dummy input and then the real one. Any ideas how I can solve this problem?

Offline kanonet

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1137
    • View Profile
    • My GLBasic code archiv
Re: Menu selection and INPUT
« Reply #1 on: 2012-Sep-09 »
If I understand you right, you have an INPUT right after pressing return, which immediately skips the INPUT, because there is still the return on the stack? I think I remember having this problem too, but I cant remember if/how I solved it. But I would recommend no to use a dummy INPUT, cause if the problem just happens on your computer and not on other players ones, they sit in front of an empty INPUT without and description what to do. Maybe you should try to move the call of INPUT to the next loop, skipp one SHOWSCREEN. I have no idea if this helps. Or you need to hope for a function FLUSHKEYS or something to clear the stack or a redo of INPUT. IF you dont get it working properly, you need to use an other way to select the menu, let user select with space instead of return, or just select menu with mouse. Sorry no real help from me. ;/
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64

Offline Ian Price

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 4176
  • On the shoulders of giants.
    • View Profile
    • My Apps
Re: Menu selection and INPUT
« Reply #2 on: 2012-Sep-09 »
Why not use something like a keypress delay value eg.

Code: (glbasic) [Select]
SETSCREEN 640,480,1

LOCAL quit%=0
LOCAL myvar$

WHILE quit=0

 PRINT "PRESS ENTER",20,20

 IF KEY(28) THEN quit=1

 SHOWSCREEN
 
WEND



LOCAL press%=20

WHILE myvar$=""

IF press=0 THEN INPUT myvar$,0,0,TRUE

IF press>0 THEN DEC press

SHOWSCREEN

WEND

What this does is ignore any key presses until the "press" value has decreased to zero (once per frame - so in this case 20 frames).
I came. I saw. I played.