callback renamed -> onEvent
This commit is contained in:
@@ -119,7 +119,7 @@ function Lv.load()
|
||||
textSize = "2vh",
|
||||
textColor = Color.new(1, 1, 1, 1),
|
||||
textAlign = enums.TextAlign.CENTER,
|
||||
callback = function(element, event)
|
||||
onEvent = function(element, event)
|
||||
if event.type == "click" then
|
||||
print("Normal button clicked!")
|
||||
end
|
||||
@@ -139,7 +139,7 @@ function Lv.load()
|
||||
textColor = Color.new(0.3, 1, 0.3, 1),
|
||||
textAlign = enums.TextAlign.CENTER,
|
||||
active = true,
|
||||
callback = function(element, event)
|
||||
onEvent = function(element, event)
|
||||
if event.type == "click" then
|
||||
element.active = not element.active
|
||||
print("Active button toggled:", element.active)
|
||||
@@ -160,7 +160,7 @@ function Lv.load()
|
||||
textColor = Color.new(0.5, 0.5, 0.5, 1),
|
||||
textAlign = enums.TextAlign.CENTER,
|
||||
disabled = true,
|
||||
callback = function(element, event)
|
||||
onEvent = function(element, event)
|
||||
-- This won't be called because button is disabled
|
||||
print("This shouldn't print!")
|
||||
end,
|
||||
@@ -179,7 +179,7 @@ function Lv.load()
|
||||
textSize = "2vh",
|
||||
textColor = Color.new(1, 1, 1, 1),
|
||||
textAlign = enums.TextAlign.CENTER,
|
||||
callback = function(element, event)
|
||||
onEvent = function(element, event)
|
||||
if event.type == "click" then
|
||||
clickCount = clickCount + 1
|
||||
element.text = "Click Me! (" .. clickCount .. ")"
|
||||
|
||||
@@ -63,7 +63,7 @@ function Lv.load()
|
||||
textColor = Color.new(1, 1, 1, 1),
|
||||
textAlign = enums.TextAlign.CENTER,
|
||||
cornerRadius = 10,
|
||||
callback = function(element, event)
|
||||
onEvent = function(element, event)
|
||||
if event.type == "click" then
|
||||
-- Fade out then fade in
|
||||
local fadeOut = Animation.fade(1.0, 1.0, 0.0)
|
||||
@@ -109,7 +109,7 @@ function Lv.load()
|
||||
textColor = Color.new(1, 1, 1, 1),
|
||||
textAlign = enums.TextAlign.CENTER,
|
||||
cornerRadius = 10,
|
||||
callback = function(element, event)
|
||||
onEvent = function(element, event)
|
||||
if event.type == "click" then
|
||||
-- Scale up
|
||||
local scaleUp = Animation.scale(
|
||||
@@ -193,7 +193,7 @@ function Lv.load()
|
||||
textColor = Color.new(1, 1, 1, 1),
|
||||
textAlign = enums.TextAlign.CENTER,
|
||||
cornerRadius = 8,
|
||||
callback = function(element, event)
|
||||
onEvent = function(element, event)
|
||||
if event.type == "click" then
|
||||
-- Fade out and in with this easing
|
||||
local fadeOut = Animation.fade(0.8, 1.0, 0.2)
|
||||
|
||||
@@ -71,7 +71,7 @@ function Lv.load()
|
||||
textColor = Color.new(1, 1, 1, 1),
|
||||
textAlign = enums.TextAlign.CENTER,
|
||||
cornerRadius = 10,
|
||||
callback = function(element, event)
|
||||
onEvent = function(element, event)
|
||||
local buttonName = event.button == 1 and "Left" or (event.button == 2 and "Right" or "Middle")
|
||||
local eventTypeName = event.type:sub(1,1):upper() .. event.type:sub(2)
|
||||
|
||||
@@ -113,7 +113,7 @@ function Lv.load()
|
||||
textColor = Color.new(1, 1, 1, 1),
|
||||
textAlign = enums.TextAlign.CENTER,
|
||||
cornerRadius = 10,
|
||||
callback = function(element, event)
|
||||
onEvent = function(element, event)
|
||||
if event.type == "click" then
|
||||
local mods = {}
|
||||
if event.modifiers.shift then table.insert(mods, "Shift") end
|
||||
@@ -152,7 +152,7 @@ function Lv.load()
|
||||
textColor = Color.new(1, 1, 1, 1),
|
||||
textAlign = enums.TextAlign.CENTER,
|
||||
cornerRadius = 10,
|
||||
callback = function(element, event)
|
||||
onEvent = function(element, event)
|
||||
if event.type == "click" then
|
||||
if event.clickCount == 1 then
|
||||
addLogEntry("Single click detected")
|
||||
@@ -237,7 +237,7 @@ function Lv.load()
|
||||
textColor = Color.new(1, 1, 1, 1),
|
||||
textAlign = enums.TextAlign.CENTER,
|
||||
cornerRadius = 5,
|
||||
callback = function(element, event)
|
||||
onEvent = function(element, event)
|
||||
if event.type == "press" then
|
||||
addLogEntry("Button 1: PRESSED")
|
||||
element.backgroundColor = Color.new(0.2, 0.3, 0.6, 1)
|
||||
@@ -259,7 +259,7 @@ function Lv.load()
|
||||
textColor = Color.new(1, 1, 1, 1),
|
||||
textAlign = enums.TextAlign.CENTER,
|
||||
cornerRadius = 5,
|
||||
callback = function(element, event)
|
||||
onEvent = function(element, event)
|
||||
if event.type == "click" then
|
||||
clickCounter = clickCounter + 1
|
||||
element.text = "Click Counter: " .. clickCounter
|
||||
@@ -278,7 +278,7 @@ function Lv.load()
|
||||
textColor = Color.new(1, 1, 1, 1),
|
||||
textAlign = enums.TextAlign.CENTER,
|
||||
cornerRadius = 5,
|
||||
callback = function(element, event)
|
||||
onEvent = function(element, event)
|
||||
if event.type == "click" then
|
||||
eventLog = {}
|
||||
addLogEntry("Log cleared!")
|
||||
|
||||
@@ -72,7 +72,7 @@ function Lv.load()
|
||||
textColor = Color.new(1, 1, 1, 1),
|
||||
textAlign = enums.TextAlign.CENTER,
|
||||
cornerRadius = 8,
|
||||
callback = function()
|
||||
onEvent = function()
|
||||
counter = counter + 1
|
||||
counterDisplay.text = "Counter: " .. counter
|
||||
end
|
||||
@@ -90,7 +90,7 @@ function Lv.load()
|
||||
textColor = Color.new(1, 1, 1, 1),
|
||||
textAlign = enums.TextAlign.CENTER,
|
||||
cornerRadius = 8,
|
||||
callback = function()
|
||||
onEvent = function()
|
||||
counter = counter - 1
|
||||
counterDisplay.text = "Counter: " .. counter
|
||||
end
|
||||
@@ -108,7 +108,7 @@ function Lv.load()
|
||||
textColor = Color.new(1, 1, 1, 1),
|
||||
textAlign = enums.TextAlign.CENTER,
|
||||
cornerRadius = 8,
|
||||
callback = function()
|
||||
onEvent = function()
|
||||
counter = 0
|
||||
counterDisplay.text = "Counter: " .. counter
|
||||
end
|
||||
|
||||
@@ -166,7 +166,7 @@ function Lv.load()
|
||||
})
|
||||
|
||||
-- Add click handler to bring to front
|
||||
box.callback = function(element)
|
||||
box.onEvent = function(element)
|
||||
maxZ = maxZ + 1
|
||||
element.z = maxZ
|
||||
element.text = "Box " .. i .. "\nZ: " .. element.z
|
||||
|
||||
@@ -249,7 +249,7 @@ function Lv.load()
|
||||
})
|
||||
|
||||
-- Add hover animation
|
||||
card.callback = function(element)
|
||||
card.onEvent = function(element)
|
||||
local anim = Animation.new({
|
||||
duration = 0.2,
|
||||
start = { opacity = 1 },
|
||||
|
||||
@@ -99,7 +99,7 @@ local function createSlider(x, y, width, label, min, max, initialValue, onValueC
|
||||
})
|
||||
|
||||
-- Make the background track interactive
|
||||
sliderBg.callback = function(element, event)
|
||||
sliderBg.onEvent = function(element, event)
|
||||
if event.type == "press" or event.type == "drag" then
|
||||
-- Get element bounds
|
||||
local bg_x = element.x
|
||||
|
||||
Reference in New Issue
Block a user