We would like to build a community for Small Basic programmers of any age who like to code. Everyone from total beginner to guru is welcome. Click here to register and share your programming journey!


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Question about a program
#5
Hi,

Another thought on your program

Changes made to the UI (GraphicsWIndow objects) from within event subroutines only take effect after the event subroutine has ended.  Consider the examples below.

Code:
'Main UI thread code
tb = Controls.AddTextBox(50,50)
GraphicsWindow.MouseDown = OnMouseDown
'Event Subroutines
Sub OnMouseDown
  Controls.SetTextBoxText(tb,"Hello World")
  Program.Delay(3000) 'Time consuming work
EndSub

Code:
'Main UI thread code

tb = Controls.AddTextBox(50,50)
GraphicsWindow.MouseDown = OnMouseDown

'Game loop

While ("True")
  If (clicked) Then
    Controls.SetTextBoxText(tb,"Hello World")
    Program.Delay(3000) 'Other time consuming work
    clicked = "" 'Reset handled flag
  EndIf
 
  Program.Delay (100) 'Don't mash cpu
EndWhile

'Subroutines

Sub OnMouseDown
  clicked = "True"
EndSub
Reply


Messages In This Thread
Question about a program - by Eddie - 07-17-2025, 04:32 PM
RE: Question about a program - by Scout - 07-17-2025, 10:01 PM
RE: Question about a program - by Eddie - Yesterday, 06:35 AM
RE: Question about a program - by litdev - Yesterday, 10:39 AM
RE: Question about a program - by litdev - 9 hours ago

Forum Jump:


Users browsing this thread: 1 Guest(s)