GetInputActive
ActiveState = GetInputActive(InputIndex)
 
Parameters:

    InputIndex = The Input handler you wish to query
Returns:

    ActiveState = The state of the input handler (0= input closed, 1= input active)
 

      The GetInputActive function gets the input state of an input handler. GetInputActive will return a False(0) when the input handler in not longer active (user has hit Enter during input) or True(1) when then the handler is ok to receive input.





FACTS:


      * The GetInputActive function is part of the "Input" expansion library. Therefore in order to use GetInputActive in program you need to include that library in your project. To do so, place I.e. #include "Input" at the top of the your program.

      * You can get the text from any input handler using the using the GetInputText() function.

      * You can manually set an input handlers active state using the InputActive() function

      * Need an old school Input replacement, see the StaticInput() function





Mini Tutorial:


      This example demonstrates the use of asynchronous input. The demo just sets up an input handler and render loop. The loop will execute until the input handler is no longer active (the user pressed Enter). It will then display the entered text message before exiting. The interesting thing about this is that since we control the input loop, we can draw pretty much anything you like while input is taking place. Which is represented by a moving circle.


  
  
; Include the Input Library
  #Include "input"
  
  
; limit the FPS rate to 60 frames per second or less
  SetFPS 60
  
  Sw=GetScreenWidth()
  Sh=GetScreenHeight()
  
  
; load the arial font as font #2, size 32
  LoadFont "arial",2,32,0
  
  
; Create a new input prompt at Xpos 20, Ypos=250,
; with a custom starting text
  MyInput     =NewInput(20,250,_
  "Example Async Input (Get Input While Your Game Updates)")
  
  
; set this input routine to use Font #2
  Inputfont MyInput,2
  
; create some variables to hold and position
; and direction of our moving ball
  x#=Rnd(sw)
  y#=Rnd(sh)
  angle#=Rnd(360)
  
  
  Repeat
   ; clear the Screen to black (rgb(0,0,0)
     Cls RGB(0,0,0)
     
     Print FPS()
     
   ; draw and move our circle
     CircleC x#,y#,50,true,RGB(0,255,0)
     x#=x#+CosRadius(angle#,2)
     y#=y#+SinRadius(angle#,2)
     If X#<0 Then x#=0 : angle#=Rnd(360)
     If X#>sw Then x#=sw : angle#=Rnd(360)
     If Y#<0 Then Y#=0 : angle#=Rnd(360)
     If Y#>sh Then Y#=sh : angle#=Rnd(360)
     
     
   ; Call the Input Poll function to update
   ; and draw this input message
     Input(MyInput)
     
     
   ; refresh the display so the user can see it
     Sync
     
   ; Loop until the user hits Enter!
  Until GetInputActive(MyInput)=false
  
; wait until no keys are being pressed
  WaitNoKey
  
  Cls RGB(0,0,0)
  
; Display what the user typed
  Print GetInputText(MyInput)
  
; Refresh the screen and wait for a key to be pressed
  Sync
  WaitKey
  




This example would output.

  
  Example Async Input (Get Input While Your Game Updates)
  

 
Related Info: Input | KeyState | Mouse | NewInput | Scancode | StaticInput :
 


(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com