Code: Select all
Function p_LayerEvent(msg)
DebugPrint("Mouse moved over layer:", msg.layer, msg.layername)
EndFunction
Function p_SwapLayers()
Local id, name$
SwapLayers(1, 2)
id, name$ = GetLayerAtPos(10, 10)
DebugPrint("Mouse clicked,", name$, "is in front.")
EndFunction
EnableLayers()
SetFillStyle(#FILLCOLOR)
Box(10, 10, 100, 100, #RED, {Name="red"})
Box(10, 10, 100, 100, #BLUE, {Name="blue"})
MakeButton(1, #LAYERBUTTON, "red", False, False, {OnMouseOver=p_LayerEvent})
MakeButton(2, #LAYERBUTTON, "blue", False, False, {OnMouseOver=p_LayerEvent})
EscapeQuit(True)
InstallEventHandler({OnMouseUp=p_SwapLayers})
Repeat
WaitEvent()
Forever
Mouse moved over layer: 2 blue
Mouse clicked, red is in front.
Mouse moved over layer: 1 blue
Mouse clicked, blue is in front.
Mouse moved over layer: 2 blue
Mouse clicked, red is in front.
Mouse moved over layer: 1 blue
As you can see, the events will come always from the layer that was in front originally even though it isn't visible anymore. Looks like button order doesn't follow the layer order.