Canvas:onClick(x, y) event


This event is fired when the user has clicked on the Canvas.

Parameters

x

The horizontal position of the mouse in the Canvas area.

y

The vertical position of the mouse in the Canvas area.

Notes

  • This function provides DIP (device independent pixels) coordinates.

Return value

This event returns no value.

Example

local ui = require "ui" require "canvas" local win = ui.Window("Canvas:onClick() event sample", "fixed", 320, 200) win:status("Click on the Canvas to change its color") -- create a Canvas local canvas = ui.Canvas(win, 0, 0, 100, 100) canvas:center() canvas.cursor = "hand" function canvas:onClick() self.bgcolor = math.random(0xFFFFFF) end canvas:onClick() ui.run(win):wait()