Using multiple screens on multiple windows

Discuss GUI programming with the RapaGUI plugin here
Post Reply
domenikov
Posts: 12
Joined: Fri May 19, 2017 10:27 pm

Using multiple screens on multiple windows

Post 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?
User avatar
jPV
Posts: 600
Joined: Sat Mar 26, 2016 10:44 am
Location: RNO
Contact:

Re: Using multiple screens on multiple windows

Post 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})
domenikov
Posts: 12
Joined: Fri May 19, 2017 10:27 pm

Re: Using multiple screens on multiple windows

Post by domenikov »

Your suggestion is correct, now is working. Thank you very much! :)
p-OS
Posts: 167
Joined: Mon Nov 01, 2010 11:56 pm

Re: Using multiple screens on multiple windows

Post 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) ?
User avatar
airsoftsoftwair
Posts: 5425
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Using multiple screens on multiple windows

Post 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...
p-OS
Posts: 167
Joined: Mon Nov 01, 2010 11:56 pm

Re: Using multiple screens on multiple windows

Post by p-OS »

Makes sense. Thanks for the clarfications.
Post Reply