|
Post by tbird on Oct 3, 2018 21:32:38 GMT -6
n00b could you give me a quick example on the ReadInput functions, I keep getting weird errors, I am guessing I have to read it in to an array?? Any help is much appreciated.
Thanks.
|
|
|
Post by n00b on Oct 4, 2018 6:25:33 GMT -6
Here is a quick example I typed up. I am going to try to make more minimal examples like this to include in the next release. ReadInput_Start starts reading text from the keyboard but it does not draw the text on the screen. ReadInput_Text is all the text that has been read from the keyboard. This will not clear itself so you will need to clear it when you are done. ReadInput_SetText can set the text that is in ReadInput_Text. Set it to a empty string to clear it. LoadFont(0,"FreeMono.ttf",16)
WindowOpen(0, "ReadInput Example", WINDOWPOS_CENTERED, WINDOWPOS_CENTERED, 640, 480, 0) CanvasOpen(0, 640, 480, 0, 0, 640, 480, 0)
SetColor(rgb(255, 255, 255))
ReadInput_Start()
Dim user_input$
backspace = true
while true user_input$ = ReadInput_Text() ClearCanvas() drawText("CTRL-A to clear text, CTRL-B to turn backspace ON/OFF", 10, 10) drawText("User Input = " + user_input$, 10, 30)
if (key(k_lctrl) Or key(k_rctrl)) And key(k_a) then ReadInput_SetText("") elseif (key(k_lctrl) Or key(k_rctrl)) And key(k_b) then backspace = not backspace ReadInput_ToggleBackspace(backspace) elseif key(k_escape) then exit while end if update() wend
ReadInput_Stop() windowClose(0)
You need to put it in the same folder as FreeMono.ttf. It is included with RCBasic but I am attaching it here for convenience. Attachments:FreeMono.ttf (578.74 KB)
|
|
|
Post by tbird on Oct 4, 2018 7:01:48 GMT -6
I had almost the same thing going on but I had the start and stop functions inside a while loop, is that possible? If not no biggy the input can just be s separate function.
|
|
|
Post by n00b on Oct 4, 2018 7:16:10 GMT -6
You can start and stop it wherever you want. Just make sure you read all the text you are trying to read before you stop it. A good example is the gui library. Every time you click inside a text box, ReadInput_Start is called. Once you click outside the textbox or press enter, ReadInput_Stop is called. I don't start and stop it at any other time.
|
|
|
Post by tbird on Oct 4, 2018 7:23:37 GMT -6
Yeah I see now, how I was doing it wrong, it works now. Thank you.
|
|