Is there currently a bug in SetTimeout or what am I doing wrong? Reading the docs, SetTimeout should return an ID that can be used to call ClearTimeout to cancel a running timeout, correct? But SetTimeout always seems to return Nil.
Here's an example:
Test.hws:
Code: Select all
@REQUIRE "RapaGUI", {Link = True}
@APPTITLE "SetTimeout-Test"
@FILE 1, "TestGUI.xml"
m_timeoutID = Nil
Function p_EventFunc(msg)
Switch(msg.ID)
Case "set":
m_timeoutID = SetTimeout(Nil, p_test, 2000)
moai.DoMethod("log", "insert", "bottom", "SetTimeout started")
moai.DoMethod("log", "insert", "bottom", "m_timeoutID: " .. ToString(m_timeoutID))
Case "clear":
ClearTimeout(m_timeoutID)
moai.DoMethod("log", "insert", "bottom", "SetTimeout cleared")
moai.DoMethod("log", "insert", "bottom", "m_timeoutID: " .. ToString(m_timeoutID))
EndSwitch
EndFunction
Function p_test()
moai.DoMethod("log", "insert", "bottom", "Timeout function executed")
EndFunction
moai.CreateApp(ReadString(1))
InstallEventHandler({RapaGUI = p_EventFunc})
Repeat
WaitEvent
Forever
Code: Select all
<?xml version="1.0" encoding="iso-8859-1"?>
<application id="app">
<window id="mainWindow" title="SetTimeout">
<vgroup>
<hgroup>
<button id="set">SetTimeout</button>
<button id="clear">ClearTimeout</button>
</hgroup>
<listview id="log" >
<column/>
</listview>
</vgroup>
</window>
</application>