I realize that my major hindrance arose from using #PB_Any. Had I taken constants as usually I might have come across the 'classic' solution halfway naturally. Though favoring more straight ways the AnyID-array solves what I struggled with and is a nice lesson to learn.
have no opportunity to test it ad hoc but it looks as if all existing gadgets would be addressed and changed
in one go.
I'd like to show you what I've been aming at and maybe you have some valuable hints about these nested event loop. As it's only meant as nice closing gimmick
it's fine so far, but ultimately it's not a proper way to do it.
Code: Select all
ci = CreateImage(#PB_Any, 100, 100 ) ; , 32| #PB_Image_Transparent
Global Dim Anyid(8)
Win_0 = OpenWindow(#PB_Any, 0, 0, 100, 100, "hui", #PB_Window_ScreenCentered | #PB_Window_BorderLess ) ;#PB_Window_SystemMenu |
StickyWindow(Win_0, 1)
img = ImageGadget(#PB_Any, 0,0, 100, 100, ImageID(ci))
Anyid(0) = StringGadget(#PB_Any, 10, 10, 20, 20, " 1") ; , #PB_String_BorderLess
Anyid(1) = StringGadget(#PB_Any, 40, 10, 20, 20, " 2") ; , #PB_String_BorderLess
Anyid(2) = StringGadget(#PB_Any, 70, 10, 20, 20, " 3") ; , #PB_String_BorderLess
Anyid(3) = StringGadget(#PB_Any, 10, 40, 20, 20, " S") ; , #PB_String_BorderLess
Anyid(4) = StringGadget(#PB_Any, 40, 40, 20, 20, " O") ; , #PB_String_BorderLess
Anyid(5) = StringGadget(#PB_Any, 70, 40, 20, 20, " L") ; , #PB_String_BorderLess
Anyid(6) = StringGadget(#PB_Any, 10, 70, 20, 20, " V") ; , #PB_String_BorderLess
Anyid(7) = StringGadget(#PB_Any, 40, 70, 20, 20, " E") ; , #PB_String_BorderLess
Anyid(8) = StringGadget(#PB_Any, 70, 70, 20, 20, " D") ; , #PB_String_BorderLess
StartDrawing(ImageOutput(ci))
DrawingMode(#PB_2DDrawing_Outlined)
Box(3,3, 94,94, $00ccff)
; Box(2,2, 96,96, $00ccff) ; alternativ with
; Box(5,5, 90,90, $00ccff) ; two borderlines
StopDrawing()
SetGadgetState(img, ImageID(ci))
Procedure recol()
For n = 0 To 2
startTime=ElapsedMilliseconds()
Repeat
WaitWindowEvent(33)
For i= 0 To 8
startTime=ElapsedMilliseconds()
Repeat
WaitWindowEvent(22) ; or
SetGadgetColor(Anyid(i), #PB_Gadget_BackColor, Random(RGB(255, 255, 255)) )
Until ElapsedMilliseconds()-startTime>4 ; or e.g. 539 or 39
Next i
Until ElapsedMilliseconds()-startTime>9
Next n
EndProcedure
recol()
; ;------------------- Alternativ version 2 ----------------
;
; Procedure recol()
; For n = 0 To 12
; startTime=ElapsedMilliseconds()
; Repeat
; WaitWindowEvent(3)
;
; For i= 0 To 8
; startTime=ElapsedMilliseconds()
; Repeat
; WaitWindowEvent(3)
; Until ElapsedMilliseconds()-startTime>22 ; en-/crease the delay
; SetGadgetColor(Anyid(i), #PB_Gadget_BackColor, Random(RGB(255, 255, 255)) )
; Next i
;
; Until ElapsedMilliseconds()-startTime>9
; Next n
; EndProcedure
;
; recol()
;
; ;------------------- -------------- ----------------
Repeat
wwe = WaitWindowEvent()
Select wwe
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Gadget
Select EventGadget()
Case img
Select EventType()
Case #PB_EventType_LeftClick
Break
Case #PB_EventType_RightClick
recol()
EndSelect
EndSelect
EndSelect
Until wwe = #PB_Event_CloseWindow