Canvas:onMouseWheel(delta, buttons)event
This event is fired when the user rotates the mouse wheel while beeing over the Canvas.
Parameters
delta
A numberthat indicates the distance the wheel is rotated, expressed in multiples or divisions of 120.
A positive value indicates that the wheel was rotated forward, away from the user, a negative value indicates that the wheel was rotated backward, toward the user.
buttons
A table which fields indicates if mouse buttons or special keys have been pressed during the mouse up event :
"left":trueif left mouse button is pressed,falseotherwise"right":trueif right mouse button is pressed,falseotherwise"middle":trueif middle mouse button is pressed,falseotherwise"control":trueif the CONTROL key is pressed,falseotherwise"shift":trueif the SHIFT mouse button is pressed,falseotherwise
Return value
The event returns no value.Example
--! luart-extensions
import ui
require "canvas"
local win = ui.Window("Canvas - onMouseWheel event example", "fixed", 320, 240)
local c = ui.Canvas(win)
c.align = "all"
local width = c.width/2
local height = c.height/2
local scale = 1
function c:onMouseWheel(delta)
scale = scale + 0.05*delta/120
end
function c:onPaint()
self:begin()
self:clear()
c:identity()
c:scale(scale, scale)
c:fillrect(width-35, height-35, width+35, height+35, 0xA569BDFF)
self:flip()
end
await win:showasync()