How to take input
BlitzPlus Forums/BlitzPlus Programming/How to take input
| ||
How do I take a number input in a blitz gui window program? |
| ||
You will have to check for events such as changes when the text is input on each keystroke then validate the value entered. If it is a non numeric value discard it. |
| ||
Easy way : with Input() More complex way : with keyhit() or keydown() and your own routine to detect which keys have been pressed and store the result as a string. Then you can use Int(XString$) to convert a string into an integer or Float(XString$) to convert a string into a float and then do what you want with it... |
| ||
Generally keyhit etc doesn't work very well with gui controls in blitzplus....I'm happy to be corrected on this but processing is slightly different because it uses events. |
| ||
With PeekEvent()... http://www.blitzbasic.co.nz/bpdocs/command.php?name=PeekEvent&ref=comments ...you can check whether there is an event. PeekEvent() will return an ID. If this ID is $103 it is an keyboard stroke and EventData()... http://www.blitzbasic.co.nz/bpdocs/command.php?name=EventData&ref=comments .... will contain the ASCII code. Now you can react as you want. With EventSource() you can check whether the source of this event is really your gadget |