Text Size

Feature Request

indexed gadgets

Request new features here

Moderators: jsp, Pharmhaus

indexed gadgets

Postby Zeke » Wed Dec 09, 2009 12:05 pm

hi, this is what im missing... when you make two gadget with same name, they goes to table with same name...

like when i add 2 Buttons.. and if i rename both to btnSelect -> then there should be "local/global btnSelect:TGadget[2]
Zeke
New Member
 
Posts: 6
Joined: Wed Dec 09, 2009 10:12 am

Build 412

Postby jsp » Wed Dec 09, 2009 1:57 pm

Hi,
is the code below what you are looking for?
If yes, it is quite a huge change for the structure as it involves really every part (header, creation, set up, event queue, parameter and function calls).
What would the benefit to use an array in this situation for you or for the structure?
How do you use the index to select an array element? Just a number or constants?
And last but not least, what are you trying to achieve? :)
Have you looked at the Gadget Commander which can create a gadget arrays automatic for you to do a certain action on the array members, it might be something you are looking for, but maybe I'm wrong?
Example:
GadgetArray1$[] = ["Button1","Button2","Button3","Button4"]
GadgetCommander(Uncheck,GadgetArray1,GadgetList:TList)

Code: Select all

SuperStrict

Import MaxGui.Drivers


Local Button1:TGadget[4]
Local Window1:TGadget = CreateWindow:TGadget("Window1",222,91,406,244,Null,WINDOW_TITLEBAR|WINDOW_RESIZABLE |WINDOW_STATUS |WINDOW_CLIENTCOORDS )
   Button1:TGadget[0] = CreateButton:TGadget("Button1",27,37,75,23,Window1:TGadget,BUTTON_RADIO)
      SetButtonState( Button1:TGadget[0],1 )
   Button1:TGadget[1] = CreateButton:TGadget("Button2",27,71,75,23,Window1:TGadget,BUTTON_RADIO)
      SetButtonState( Button1:TGadget[1],0 )
   Button1:TGadget[2] = CreateButton:TGadget("Button3",27,111,75,23,Window1:TGadget,BUTTON_RADIO)
      SetButtonState( Button1:TGadget[2],0 )
   Button1:TGadget[3] = CreateButton:TGadget("Button4",27,151,75,23,Window1:TGadget,BUTTON_RADIO)
      SetButtonState( Button1:TGadget[3],0 )

Repeat
   WaitEvent()
   Select EventID()
      Case EVENT_WINDOWCLOSE
         Select EventSource()
            Case Window1   Window1_WC( Window1:TGadget )
         End Select

      Case EVENT_GADGETACTION
         Select EventSource()
            Case Button1[0]   Button1_Array0_GA( Button1:TGadget[0] )
            Case Button1[1]   Button1_Array1_GA( Button1:TGadget[1] )
            Case Button1[2]   Button1_Array2_GA( Button1:TGadget[2] )
            Case Button1[3]   Button1_Array3_GA( Button1:TGadget[3] )
         End Select

   End Select
Forever

Function Logic_Gui_WC( Window:TGadget )
   DebugLog "Window Logic_Gui wants to be closed"

   End
End Function

Function Window1_WC( Window:TGadget )
   DebugLog "Window Window1 wants to be closed"

   End
End Function

Function Button1_Array0_GA( Button:TGadget )
   DebugLog "Button Button1_[0] was pressed"
   
End Function

Function Button1_Array1_GA( Button:TGadget )
   DebugLog "Button Button1_[1] was pressed"
   
End Function

Function Button1_Array2_GA( Button:TGadget )
   DebugLog "Button Button1_[2] was pressed"
   
End Function

Function Button1_Array3_GA( Button:TGadget )
   DebugLog "Button Button1_[3] was pressed"
   
End Function
User avatar
jsp
LogicZone
 
Posts: 372
Joined: Sun Sep 09, 2007 11:18 pm
Location: Germany

Postby Zeke » Thu Dec 31, 2009 7:29 pm

yea that code is just what i want.. becaus if i want to use a lots of checkbox/radio buttons.. its more easier to use for loop to check their status.. BUT i know.. i can use one variable and set/clear bits of that var...
and then use that variable.. thats ok..
Zeke
New Member
 
Posts: 6
Joined: Wed Dec 09, 2009 10:12 am


Return to Feature Request

Who is online

Users browsing this forum: No registered users and 1 guest

cron

User Menu

Login form



Who is online

In total there is 1 user online :: 0 registered, 0 hidden and 1 guest (based on users active over the past 5 minutes)
Most users ever online was 71 on Fri Apr 08, 2016 9:16 pm

Users browsing this forum: No registered users and 1 guest