Page 1 of 1

Using multiple screens on multiple windows

Posted: Sun Nov 28, 2021 2:58 pm
by domenikov
I have a problem using multiple screens on multiple windows created with RapaGUI. Precisely, if I create two windows with one screen each, when I try to click the mouse on the first screen created, the event is detected correctly, while instead clicks made on the other screen are ignored. An example that highlights what happens:

Code: Select all

@VERSION 9,0
@REQUIRE "RapaGUI", {Link = True}
@DISPLAY 1,{Width=500, Height=500, Color=#WHITE}
@DISPLAY 2,{Width=500, Height=500, Color=#WHITE}

Function p_EventFunc(msg)
	Switch msg.action			
		Case "OnMouseDown":
			; User clicked on a screen
			DebugPrint("User clicked on screen:"..msg.ID)
		Case "RapaGUI":
		Switch msg.attribute
			; User close program
			Case "CloseRequest":
				End
		EndSwitch
	EndSwitch

EndFunction	

XML$="<?xml version=\"1.0\" encoding=\"iso-8859-1\"?><application id=\"DemoApp\">"
XML$=XML$.."<window title=\"Window1\" id=\"Window1\" notify=\"CloseRequest\"><vgroup><hollywood display=\"1\"/></vgroup></window>"
XML$=XML$.."<window title=\"Window2\" id=\"Window2\" notify=\"CloseRequest\"><vgroup><hollywood display=\"2\"/></vgroup></window>"
XML$=XML$.."</application>"

moai.CreateApp(XML$)
InstallEventHandler({RapaGUI = p_EventFunc})
InstallEventHandler({OnMouseDown = p_EventFunc})

Repeat
	WaitEvent
Forever
The program opens two windows. Selecting the screen contained in "Window1", the message "User clicked on screen:1" is printed correctly. Selecting the screen on the other window should print "User clicked on screen:2", but nothing happens.

I'm using Hollywood 9 and RapaGUI 2.1.

Where is the mistake?

Re: Using multiple screens on multiple windows

Posted: Sun Nov 28, 2021 5:14 pm
by jPV
You'll have to install these kind of event handlers for each display separately, so add these two lines into your script:

Code: Select all

SelectDisplay(2)
InstallEventHandler({OnMouseDown = p_EventFunc})

Re: Using multiple screens on multiple windows

Posted: Sun Nov 28, 2021 7:28 pm
by domenikov
Your suggestion is correct, now is working. Thank you very much! :)

Re: Using multiple screens on multiple windows

Posted: Mon Nov 29, 2021 7:37 pm
by p-OS
I am a long time Hollywood user, but also was not aware of the fact, that EventHandler are bound to a specific Display Handler.
Is this valid for some handlers only or for any (e.g. network handler) ?

Re: Using multiple screens on multiple windows

Posted: Fri Dec 03, 2021 6:38 pm
by airsoftsoftwair
p-OS wrote: Mon Nov 29, 2021 7:37 pm I am a long time Hollywood user, but also was not aware of the fact, that EventHandler are bound to a specific Display Handler.
Is this valid for some handlers only or for any (e.g. network handler) ?
No, only for display handlers because I think it makes sense to install these on a per display basis. E.g. imagine you have multiple displays but you want "OnMouseMove" events only for one of them. Since mouse moves are high traffic events, it would be a waste of CPU cycles if they were sent to all displays when you only needed them on one...

Re: Using multiple screens on multiple windows

Posted: Sat Dec 04, 2021 12:23 am
by p-OS
Makes sense. Thanks for the clarfications.