Page 1 of 1

Multi Display

Posted: Thu Oct 27, 2022 2:45 pm
by sinisrus
Hello,

I don't understand why nothing happens when I select window or if I close a window, the whole program closes ?! Thanks in advance !

Code: Select all

@DISPLAY 1, {X=50,Y=150, Width=100, Height=100,color=#WHITE}

Win1=CreateDisplay(NIL, {X=50,Width=200, Height=200,color=$FF0000})   OpenDisplay(Win1)
Win2=CreateDisplay(NIL, {X=300,Width=200, Height=200, color=$00FF00}) OpenDisplay(Win2)
Win3=CreateDisplay(NIL, {X=550,Width=200, Height=200, color=$0000FF}) OpenDisplay(Win3)

Function  p_EventFunc(msg)
    Switch msg.action
    CASE "ActiveWindow": DebugPrint(msg.id)
    CASE "CloseWindow":  DebugPrint(msg.id)
    EndSwitch
EndFunction

; listen to these events!
InstallEventHandler({CloseWindow = p_EventFunc, ActiveWindow = p_EventFunc})

EscapeQuit(True)

; Boucle infinie
Repeat
        WaitEvent
Forever

Re: Multi Display

Posted: Thu Oct 27, 2022 3:40 pm
by jPV
Window related event handlers are per display, so you must install handlers for each display separately. Now you have only installed them for the last display/window.

This should do the trick:

Code: Select all

; listen to these events!
InstallEventHandler({CloseWindow = p_EventFunc, ActiveWindow = p_EventFunc})
SelectDisplay(1)
InstallEventHandler({CloseWindow = p_EventFunc, ActiveWindow = p_EventFunc})
SelectDisplay(Win1)
InstallEventHandler({CloseWindow = p_EventFunc, ActiveWindow = p_EventFunc})
SelectDisplay(Win2)
InstallEventHandler({CloseWindow = p_EventFunc, ActiveWindow = p_EventFunc})

Re: Multi Display

Posted: Thu Oct 27, 2022 4:01 pm
by sinisrus
Great, thank you ! I had forgotten