Hello,
I have problem with multi Display and MakeButton
see my script for help me :
-----------------------
/* Nouveau projet Hollywood */
W=100
H=100
POSX={100,300,500}
FOR A=0 TO 2
CreateDisplay(A,{X=POSX[A], Y=350, Width = W, Height = H, Borderless=0, Fixed=0,Title="Win"..A})
SelectDisplay(A)
CreateBrush(1, W, H ,"$5D5D5D")
SelectBrush(1)
POS=3
FOR B=0 TO 4
SetFillStyle(#FILLNONE)
BOX(2,POS,96,20,#BLUE) TextOut(#CENTER,POS+6,"Button"..B)
POS=POS+25
NEXT
EndSelect
DisplayBrush(1,0,0)
OpenDisplay(A)
ActivateDisplay(A)
POS=3
FOR B=0 TO 4
Action={
OnMouseUp = Function(msg) test(msg) EndFunction,
OnMouseOver = Function(msg) test(msg) EndFunction,
OnMouseOut = Function(msg) test(msg) EndFunction
}
MakeButton(B, #SIMPLEBUTTON, 2, POS, 96, 20, Action)
POS=POS+25
NEXT
NEXT
Function test(msg)
;debugprint(msg.id,msg.y)
Switch msg.ACTION
CASE "OnMouseOver":
BOX(2,msg.y,96,20,#RED)
CASE "OnMouseOut":
BOX(2,msg.y,96,20,#BLUE)
EndSwitch
EndFunction
/* Boucle infinie */
Repeat
WaitEvent
Forever
Multi Display and MakeButton
- airsoftsoftwair
- Posts: 5446
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
Re: Multi Display and MakeButton
That's a bug in your code. You're using the same IDs for the buttons in every display but IDs must be unique. Use IDs 0 to 4 for display 1, IDs 5 to 9 for display 2, and IDs 10 to 14 for display 3 and it should work.
By the way, please use the "code" tag when posting code...
By the way, please use the "code" tag when posting code...
Re: Multi Display and MakeButton
By the way, please use the "code" tag when posting code...
Ok sorry
I tested your solution and not work :-/
Ok sorry
I tested your solution and not work :-/
Code: Select all
/* Nouveau projet Hollywood */
W=100
H=100
POSX={100,300,500}
BTID=0
FOR A=0 TO 2
CreateDisplay(A,{X=POSX[A], Y=350, Width = W, Height = H, Borderless=0, Fixed=0,Title="Win"..A})
SelectDisplay(A)
CreateBrush(1, W, H ,"$5D5D5D")
SelectBrush(1)
POS=3
FOR B=0 TO 4
SetFillStyle(#FILLNONE)
BOX(2,POS,96,20,#BLUE) TextOut(#CENTER,POS+6,"Button"..B)
POS=POS+25
NEXT
EndSelect
DisplayBrush(1,0,0)
OpenDisplay(A)
ActivateDisplay(A)
POS=3
FOR B=0 TO 4
Action={
OnMouseUp = Function(msg) test(msg) EndFunction,
OnMouseOver = Function(msg) test(msg) EndFunction,
OnMouseOut = Function(msg) test(msg) EndFunction
}
MakeButton(BTID, #SIMPLEBUTTON, 2, POS, 96, 20, Action)
POS=POS+25
BTID=BTID+1
NEXT
NEXT
Function test(msg)
;debugprint(msg.id,msg.y)
Switch msg.ACTION
CASE "OnMouseOver":
BOX(2,msg.y,96,20,#RED)
CASE "OnMouseOut":
BOX(2,msg.y,96,20,#BLUE)
EndSwitch
EndFunction
/* Boucle infinie */
Repeat
WaitEvent
Forever
- airsoftsoftwair
- Posts: 5446
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
Re: Multi Display and MakeButton
Oops, sorry, please forget my previous reply. Buttons are of course private to BGPics so it's absolutely valid to re-use identifiers. The problem lies elsewhere: Your event callback always draws to the *current* display and this is always display 2 in your case. In order to draw to the other displays you first need to select them when you get their events. Here's how you can do that:
Code: Select all
/* Nouveau projet Hollywood */
W=100
H=100
POSX={100,300,500}
For A=0 To 2
CreateDisplay(A,{X=POSX[A], Y=350, Width = W, Height = H, Borderless=0, Fixed=0,Title="Win"..A})
SelectDisplay(A)
CreateBrush(1, W, H ,"$5D5D5D")
SelectBrush(1)
POS=3
For B=0 To 4
SetFillStyle(#FILLNONE)
Box(2,POS,96,20,#BLUE) TextOut(#CENTER,POS+6,"Button"..B)
POS=POS+25
Next
EndSelect
DisplayBrush(1,0,0)
OpenDisplay(A)
ActivateDisplay(A)
POS=3
For B=0 To 4
Action={
OnMouseUp = Function(msg) test(msg) EndFunction,
OnMouseOver = Function(msg) test(msg) EndFunction,
OnMouseOut = Function(msg) test(msg) EndFunction
}
MakeButton(B, #SIMPLEBUTTON, 2, POS, 96, 20, Action)
POS=POS+25
Next
Next
Function test(msg)
; HERE IS THE FIX: first select the button's display before drawing to it!
SelectDisplay(msg.display, True)
Switch msg.ACTION
Case "OnMouseOver":
Box(2,msg.y,96,20,#RED)
Case "OnMouseOut":
Box(2,msg.y,96,20,#BLUE)
EndSwitch
EndFunction
/* Boucle infinie */
Repeat
WaitEvent
Forever
Re: Multi Display and MakeButton
yessss nice work
thank you )
thank you )