zerohero95
New Member
- Joined
- May 12, 2024
- Messages
- 2
- Reaction score
- 0
Is there a tick function for modal windows? I want to move a button across the screen idly but can only move it when I click on the button. I've tried making a function and calling g_clock.scheduleEvent, g_dispatcher.addEvent, and scheduleEvent but have had no success. I understand that I am using print statements for some of the events, they are to just debug and try to see if they consistently run, which they do not. Here is how im implementing my code.
Lua:
jumpbuttonButton = nil
jumpbuttonWindow = nil
function init()
jumpbuttonButton = modules.client_topmenu.addRightToggleButton('jumpbuttonButton', tr('Jump Button'), '/jumpbutton/jumpbutton/jumpbutton', closing)
jumpbuttonButton:setOn(false)
jumpbuttonWindow = g_ui.displayUI('jump_button')
jumpbuttonWindow:setVisible(false)
--get help values
allTabs = jumpbuttonWindow:recursiveGetChildById('allTabs')
allTabs:setContentWidget(jumpbuttonWindow:getChildById('optionsTabContent'))
jump = g_ui.createWidget('Button')
jump:setOn(true)
jump:setPosition({x = 250, y = 300})
jump:setSize({width = 20, height = 20})
jumpbuttonWindow:addChild(jump)
jump.onClick = function()
print('Button clicked!')
moveButton()
end
scheduleEvent(function() print("printing in innit") end, 1000)
end
function terminate()
jumpbuttonButton:destroy()
jumpbuttonWindow:destroy()
end
function moveButton()
local position
position = positionGlobal
position.x = position.x - 10
jump:setPosition(position)
end
function printer()
print("should be existing")
end
-- scheduleEvent here
scheduleEvent(function() print("1 second delay") end, 1000)
-- g_clock.schedulEvent here
if jump ~= nil then
g_clock.scheduleEvent(moveButton, 0)
end
--g_dispatcher.addEvent here
g_dispatcher.addEvent(printer)