Re: [PB Cocoa] Methods, Tips & Tricks
Posted: Thu Dec 06, 2012 10:37 pm
Toggle animation in moving ProgressBar on and off (only possible in Snow Leopard or older):
Code: Select all
If OSVersion() > #PB_OS_MacOSX_10_6
MessageRequester("Info", "Sorry, but stopping a progressbar's animation is no longer possible beginning with Lion...")
End
EndIf
OpenWindow(0, 270, 100, 320, 100, "Toggle ProgressBar animation")
ProgressBarGadget(0, 10, 20, 300, 30, 0, 100)
SetGadgetState(0, 0)
ButtonGadget(1, 90, 65, 130, 25, "Stop Animation")
AnimationEnabled = #True
AddWindowTimer(0, 0, 100)
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Timer
CurrentValue = GetGadgetState(0)
If CurrentValue = 100
SetGadgetState(0, 0)
Else
SetGadgetState(0, CurrentValue + 1)
If AnimationEnabled = #False
CocoaMessage(0, GadgetID(0), "stopAnimation:$", @"self")
EndIf
EndIf
Case #PB_Event_Gadget
If EventGadget() = 1 And EventType() = #PB_EventType_LeftClick
AnimationEnabled ! 1
If AnimationEnabled
CocoaMessage(0, GadgetID(0), "startAnimation:$", @"self")
SetGadgetText(1, "Stop Animation")
Else
CocoaMessage(0, GadgetID(0), "stopAnimation:$", @"self")
SetGadgetText(1, "Start Animation")
EndIf
EndIf
EndSelect
ForEver