-
Notifications
You must be signed in to change notification settings - Fork 0
Canvas and events
When the code is run, A canvas is shown for drawing a GUI, this canvas takes an image and draws it.
You can draw on the canvas using the built-in function drawOnCanvas(image)
(Note that image is a primitive data type, you can access the primitive data type from the Image library through the Bitmap
member).
once drawOnCanvas is called, the image supplied will be shown on the screen, further user interactions are managed through Events.
This section may be updated periodically.
Events are actions that the user does, and calls to a method in a handler class with the parameters of the action.
The available events are:
- 'CanvasMouseClick': occurs when the user presses any mouse button on the canvas, supplies the X, Y co-ordinates of the click.
- 'CanvasMouseMove': occurs when the user moves the mouse over the canvas, supplies the X, Y co-ordinates of the mouse.
- 'CanvasKeyPress': occurs when the user presses a keyboard key, supplies the KeyCode variable, and can be translated through the Keys class.
The given class must implement the method the same name as the event name.
To register an instance of a class as the handler of a specific event, You can use the registerHandler(eventName, HandlerClass)
built-in function.
Example:
class HandlerClass
function HandlerClass()
#Nothing to do here
endfunction
function CanvasMouseClick(X as integer, Y as integer)
print X, Y;
endfunction
endclass
registerHandler("CanvasMouseClick", new HandlerClass());
scan END;
scan END;
can be used to make the program stop and wait for input while processing events.