Events are things related to your hardware. They are events like mouseMove, buttonClick, keyDown, keyUp and timer tick.
Events in Small Basic are Asynchronous. i.e. they happen independently of the program.
You need to register an event and assign it to a handler e.g.
GraphicsWindow.MouseDown = OnMouseDown.
The handler is a special subroutine that reacts independently when that event happens.
myShapeSize = 60
myShape = Shapes.AddRectangle(myShapeSize, myShapeSize)
GraphicsWindow.MouseDown = OnMouseDown
GraphicsWindow.MouseUp = OnMouseUp
mseX = GraphicsWindow.MouseX
mseY = GraphicsWindow.MouseY
X = Shapes.GetLeft(myShape)
Y = Shapes.GetTop(myShape)
If mouseDown Then
If mseX > X And mseX < X + myShapeSize Then
If mseY > Y And mseY < Y + myShapeSize Then
select = myShape
mouseDown = "False"
If mouseUp Then
select = ""
mouseUp = "False"
Shapes.Move(select, mseX, mseY)
mouseDown = "True"
mouseUp = "True"
In the sample (drag and drop) the handle sets a flag
mouseDown = "True" then picks this up in the main loop then sets
the flag to "false" ready for another event to take place.
button = Controls.AddButton("Click Me", 10, 20)
Controls.ButtonClicked = OnButtonClicked
If buttonClicked Then
buttonClicked = ""
buttonClicked = "True"