Notes
- This function provides DIP (device independent pixels) coordinates.
Canvas:onMouseUp(x, y, buttons)event
This event is fired when the user releases a mouse button while beeing over 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.
buttons
A table which fields indicates if mouse buttons or special keys have been pressed during the mouse up event :
"left": true if left mouse button is pressed, false otherwise"right": true if right mouse button is pressed, false otherwise"middle": true if middle mouse button is pressed, false otherwise"control": true if the CONTROL key is pressed, false otherwise"shift": true if the SHIFT mouse button is pressed, false otherwiseReturn value
The event returns no value.Example
--! luart-extensions
import ui
require "canvas"
-- create a fixed Window
local win = ui.Window("Canvas:onMouseUp() event sample", "fixed", 320, 200)
win:status("")
-- create a Canvas
local canvas = ui.Canvas(win, 0, 0, 100, 100)
canvas.cursor = "cross"
canvas.bgcolor = 0xFFA0A0FF
canvas:center()
function canvas:onMouseUp(x, y, buttons)
local btn = ""
if buttons.left then btn = btn.." left" end
if buttons.right then btn = btn.." right" end
if buttons.middle then btn = btn.." middle" end
if buttons.shift then btn = btn.." shift" end
win:status("x : "..math.floor(x), "y : "..math.floor(y), "buttons : "..(btn == "" and "none" or btn))
end
await win:showasync()