I tried to replace Hollywood's`WaitLeftMouse` function by an own version.
Reason: When waiting with `WaitLeftMouse` the entire script execution is stopped, means no other events can be processed, e.g. timer event. I display a clock on screen that I want to be working continuously even when actively waiting for other events.
So, I thought, to be smart by just calling `WaitEvent()`, ignoring all events but `OnMouseButton` event.
It works, but only if not called in a function that was triggered by an event. See code below.
Code: Select all
@VERSION 8,0
@DISPLAY { Title = "Test", Width=800, Height=600, Mode="Windowed", Color = #BLACK }
EnableLayers()
EscapeQuit(True)
Function p_Dummy() EndFunction
Function p_WaitLeftMouse()
DebugPrint("Waiting for MouseButton")
InstallEventHandler({OnMouseDown = p_Dummy})
While True
Local info = WaitEvent()
If info.action = "OnMouseDown" And info.triggered=1 Then Break
Wend
DebugPrint("Got MouseButton")
InstallEventHandler({OnMouseDown = 0})
EndFunction
Function p_WaitForMouseTest()
p_WaitLeftMouse()
EndFunction
Function p_Test()
;does not work:
SetInterval(1,p_WaitForMouseTest,2000)
EndFunction
; works fine:
DebugPrint("Wait 1")
p_WaitLeftMouse()
DebugPrint("Wait 2")
p_WaitLeftMouse()
DebugPrint("Wait 3")
p_WaitLeftMouse()
DebugPrint("Wait 4")
p_WaitLeftMouse()
p_Test()
Repeat
WaitEvent
Forever
The error message seems not to be fittingWrong usage/parameters for this command! Read the documentation! File: test.hws (current line: 15 - in function: WaitEvent)
But I guess there is a good reason, why this is not possible?
Cheers,
nexus