Checkbox:onHover(x, y, buttons) event
This event is fired when the user moves the mouse pointer over the Checkbox.
Parameters
x
The horizontal position of the mouse in the Checkbox area (zero means the left border of the widget).
y
The vertical position of the mouse in the Checkbox area (zero means the top border of the widget).
buttons
A table
which fields indicates if mouse buttons or special keys have been pressed during the move :
"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
otherwise
Return value
The event returns no value.Example
local ui = require "ui"
-- create a custom widget from a Checkbox
local LinkCheckbox = Object(ui.Checkbox)
-- create a custom constructor for LinkCheckbox
function LinkCheckbox.constructor(self, ...)
ui.Checkbox.constructor(self, ...)
self.cursor = "hand"
end
-- sets the onHover event
function LinkCheckbox:onHover()
self.fontstyle = { underline = true }
end
-- sets the onLeave event
function LinkCheckbox:onLeave()
self.fontstyle = { underline = false }
end
-- create a window
local win = ui.Window("Checkbox:onLeave() sample", 320, 200)
--create a LinkCheckbox object
local checkbox = LinkCheckbox(win, "Click Me !", 120, 75)
function checkbox:onClick()
win:status("LinkCheckbox is "..(self.checked and "checked" or "unchecked"))
end
checkbox:onClick()
ui.run(win):wait()