EventHandler on multiple windows

Find quick help here to get you started with Hollywood
Post Reply
amyren
Posts: 431
Joined: Thu May 02, 2019 11:53 am

EventHandler on multiple windows

Post by amyren »

Does eventhandler need to be installed seperately for each display or perhaps I install it wrongly here?

When running this code it only seem to detect events from the Display 2 window. Uncommenting those 3 lines near the bottom will make it take events from both windows.

Code: Select all

@DISPLAY {Title = "Display 1", X = #LEFT, Y = #TOP}

CreateDisplay(2, {Title = "Display 2", X = 100, Y = 100})
OpenDisplay(2)

Function p_HandlerFunc(msg)
	Switch(msg.Action)
	Case "OnMouseDown": 
		Switch(msg.id)
		Case 1:
			DebugPrint("Display 1 LMB")
		Case 2:
			DebugPrint("Display 2 LMB")
		EndSwitch
	Case "OnRightMouseDown":
		Switch(msg.id)
		Case 1:
			DebugPrint("Display 1 RMB")
			OpenDisplay(2)
		Case 2:
			DebugPrint("Display 2 RMB")
			CloseDisplay(2)
		EndSwitch
	Case "CloseWindow":
		Switch(msg.id)
		Case 1:
			Wait(50)
			CloseDisplay(1)
			End
		Case 2:
			CloseDisplay(2)
		EndSwitch
	EndSwitch
EndFunction

InstallEventHandler({OnMouseDown = p_HandlerFunc, OnRightMouseDown = p_HandlerFunc, CloseWindow = p_HandlerFunc})
;SelectDisplay(1)
;InstallEventHandler({OnMouseDown = p_HandlerFunc, OnRightMouseDown = p_HandlerFunc, CloseWindow = p_HandlerFunc})
;SelectDisplay(2)

Repeat
	WaitEvent()
Forever
Post Reply