Label:onMouseDown(button, x, y) event
This event is fired when the user presses a mouse button while beeing over the Label.
Parameters
button
A string indicating the button that has been pressed : "right"
, "middle"
or "left"
.
x
The horizontal position of the mouse in the Label area (zero means the left border of the widget).
y
The vertical position of the mouse in the Label area (zero means the top border of the widget).
Return value
The event returns no value.Example
local ui = require "ui"
-- create a window
local win = ui.Window("Label:onMouseDown() sample", 400, 300)
local label = ui.Label(win, "Move the mouse over the Label and press a mouse button!")
label.textalign = "center"
label:center()
-- set a onMouseDown() event : display a status bar with the pressed mouse button and its position
function label:onMouseDown(b, x, y)
win:status("Mouse button : "..b, "Mouse position : "..x..", "..y)
end
ui.run(win):wait()