kagehi
Member in Training
Posts: 26
|
Post by kagehi on Feb 6, 2021 22:25:23 GMT
Trying to do something where I need to update the contents of other fields, if someone changes a value in a single textbox. In most languages you can create an event handler for this, but.. Doesn't seem like JustBasic supports this... Am I wrong, or do I have to do something absurd, like keep checking if the field changed in code?
|
|
|
Post by B+ on Feb 6, 2021 23:32:27 GMT
Did you do something absurd like checking Help? Well checked textbox does not but texteditor does have: JB model is not events programming, usually one fills or modifies a textbox and then clicks a button for processing contents.
|
|
kagehi
Member in Training
Posts: 26
|
Post by kagehi on Feb 6, 2021 23:57:46 GMT
Hmm. That is what I kind of figured... I did check help, but.. some things are not done in "sensible" ways in JB, as they would in almost any other Windows language (like those in Visual Studio), so.. figured maybe something was hiding some place.
Its not a major deal, but it just would have been easier for some things. In this case it was mostly for a character tracker, so I would have to either have things update "if" a stat, or other data, was changed, or have a button, to "recalc" the contents.
I guess no one is going to be writing a spreadsheet in JB. lol
|
|
|
Post by cundo on Feb 7, 2021 1:11:53 GMT
What you could do is to read its contents using a Timer.
|
|
kagehi
Member in Training
Posts: 26
|
Post by kagehi on Feb 7, 2021 2:12:58 GMT
Yeah. Will figure something out.
|
|
|
Post by B+ on Feb 7, 2021 2:13:30 GMT
Or you can do it the easy way and check the textbox contents and all the others when the processing button is pressed.
|
|
|
Post by Rod on Feb 7, 2021 9:08:05 GMT
When you say other languages offer text box change events that usually fires when the text control loses focus. If you think about it that makes sense since you don't want to be reacting to every character keyed. That would be hard work indeed if they were keying an number how would you ever know when to react?. You can check the focus using Liberty BASIC, which would at least get you the complete input. Reading the contents with a timer works but you face the same problem, is the number complete or half done?
If the gui has an update button or calculate button both you and the user work in harmony.
|
|
|
Post by honky on Feb 7, 2021 15:46:03 GMT
Time for extraction and storage in array of 10 textboxes with "!contents? var$" = 0 ms Where's the problem ? No problem.
|
|
|
Post by Rod on Feb 7, 2021 18:43:26 GMT
The problem is knowing when the user input is complete. Moving focus suggests completion. Just looking at a text box once or on a timed basis really tells you nothing about the input. But we have left the OP behind.
|
|
|
Post by cundo on Feb 9, 2021 0:51:12 GMT
Not sure if this is of help, but here it is anyway
nomainwin
WindowWidth = 392 : WindowHeight = 180 UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2)
textbox #main.textbox1, 26, 16, 75, 25 statictext #main.st1 "+", 116,19,20,25 textbox #main.textbox2, 142, 16, 75, 25 statictext #main.st2 "=", 231,19,20,25 textbox #main.textbox3, 262, 16, 75, 25 button #main.button4, "&Quit", [buttonClick], UL, 246, 111, 122, 25 open "Textboxes-Timer test" for window as #main print #main, "trapclose [quit.main]"
print #main, "font Arial 10"
#main.textbox1 "1" #main.textbox2 "2"
[reDo] timer 0
#main.textbox1 "!contents? a$" #main.textbox2 "!contents? b$" #main.textbox3 val(a$)+val(b$)
timer 150, [reDo] wait
[quit.main] Close #main END
[buttonClick] close #main : end
|
|