DisableGadget() does'nt works within loop or procedure

Mac OSX specific forum
User avatar
michel51
Enthusiast
Enthusiast
Posts: 290
Joined: Mon Nov 21, 2005 10:21 pm
Location: Germany

DisableGadget() does'nt works within loop or procedure

Post by michel51 »

with the following code I will toggle the gadgets on and off.
But only one time, after leaving the loop or the procedure (switch on the 2 lines)
the gadgets are disabled.

Code: Select all

Enumeration
   #Window_0
   #Button_1
   #TxtGad_1
   #StrGad_1
EndEnumeration

   #Win0_x = 50
   #Win0_y = 50
   #Win0_w = 400
   #Win0_h = 400
   #Win0_Title = "Test - Test - Test"
   #Win0_Flags = #PB_Window_ScreenCentered | #PB_Window_SystemMenu  ; | #PB_Window_TitleBar

Procedure Mark_C_Line()
   Protected on.b
   on = 1
   
   For i = 1 To 5
   
      DisableGadget(#TxtGad_1, on)
      DisableGadget(#Button_1, on)
      
      on = 1 - on
      Debug "i: "+Str(i)
      Debug on

      Delay(500)
      
   Next
EndProcedure

Procedure Open_Window_0()
   If OpenWindow(#Window_0, #Win0_X, #Win0_Y, #Win0_W, #Win0_H, #Win0_Flags, #Win0_Title) = 0
      MessageRequester("Error","Konnte Hauptfenster nicht oeffnen.") : End
   EndIf
EndProcedure

Procedure Create_Gadgets_1()
   If CreateGadgetList(WindowID(#Window_0)) = 0
      MessageRequester("Error"," Konnte Gadget-Liste nicht anlegen.") : End
   EndIf
      TextGadget(#TxtGad_1, 10, 60+i*30, 100, 20, "Disable-Test", #PB_Text_Right) 
      ButtonGadget(#Button_1, 210, 60+i*30, 70, 20, "Test") 
EndProcedure

Open_Window_0()
Create_Gadgets_1()

on.b = 1
Repeat
   Evnt = WaitWindowEvent()
;   
   If Evnt = #PB_Event_Gadget
;    
      For i = 1 To 5
            
         DisableGadget(#TxtGad_1, on)
         DisableGadget(#Button_1, on)
         
         on = 1 - on
         Debug "i: "+Str(i)
         Debug on
         Delay(500)
         
      Next
      
; ### use procedure ###

;          Mark_C_Line()
;          Delay(20)
         
   EndIf   

Until Evnt = #PB_Event_CloseWindow
End
   
Is this a bug in 3.94d or is my code wrong?
In 3.94c it worked fine.

Thanks for help.
michel51

Mac OS X Snow Leopard (10.6.8 ) Intel
PureBasic V 5.21(x64), V 5.22beta