It is currently Fri May 24, 2013 2:46 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Dynamic creation of gadgets - PB Event Gadget to detect...
PostPosted: Sun Mar 11, 2012 5:23 pm 
Offline
User
User

Joined: Tue Jan 01, 2008 4:35 pm
Posts: 17
Location: UK
Hi all
Am starting to lose hair over this one... so hopefully someone can help me...

I have a structure to store some names I take from a database, and two gadgets - one for the button and one for the associated label:
Code:
Structure ListOfNamesStructure
  FirstName.s
  LastName.s
  NameGadgetNumber.i
  ButtonGadgetNumber.i
EndStructure
Global Dim ListOfNamesArray.ListOfNamesStructure(0)


Then, I create the gadgets associated with this dynamically into a scroll area, and pop the gadget numbers into the structure:
Code:
    OpenGadgetList(#ScrollArea_ChooseNameFromList)
    For n = 0 To ArraySize(ListOfNamesArray())
      ListOfNamesArray(n)\ButtonGadgetNumber = ButtonGadget(#PB_Any,0,(n*40)+10,50,20,ActionSelected)
      ListOfNamesArray(n)\NameGadgetNumber = TextGadget(#PB_Any,60,n*40,GadgetWidth(#ScrollArea_ChooseNameFromList)-100,40,ListOfNamesArray(n)\LastName + ", " + ListOfNamesArray(n)\FirstName)
    Next
    CloseGadgetList()


So far, so good. The structure contains all the gadgets, so I can free them when needed. Now all I need to do is make things happen when I click the relevant button (e.g. pass the relevant location through to a procedure to make things happen)... however:
Code:
Repeat
  Event = WaitWindowEvent(100)
  Select Event
    Case #PB_Event_Gadget
      Select EventGadget()
        Case ListOfNamesArray(0)\ButtonGadgetNumber To ListOfNamesArray(ArraySize(ListOfNamesArray()))\ButtonGadgetNumber
          Debug "In List"
          For o = 0 To ArraySize(ListOfNamesArray())
            If ListOfNamesArray(o)\ButtonGadgetNumber = EventGadget()
              Break
            EndIf
          Next
          MakeStuffHappenHere(o)
      EndSelect
  EndSelect
ForEver

doesn't work

The array is populated dynamically throughout the rest of the program... emptied, resized etc... would this be causing it to not play ball? The gadgets are all freed before the array is played about with

Any pointers? I use similar code on some other buttons that are created once... but not changed like I do here

Edit:
I have also tried:
Code:
        Select EventGadget()
        Default
          For q = 0 To ArraySize(ListOfNamesArray())
            If ListOfNamesArray(q)\ButtonGadgetNumber = EventGadget()
              Break
            EndIf
          Next
          MakeStuffHappenHere(q)

...but that also seems to trigger sometimes if you use the mouse scroll wheel on the scroll area


Last edited by sdebenham on Sun Mar 11, 2012 5:34 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Dynamic creation of gadgets - PB Event Gadget to detect.
PostPosted: Sun Mar 11, 2012 5:32 pm 
Online
Addict
Addict
User avatar

Joined: Wed Dec 23, 2009 10:14 pm
Posts: 1386
Location: Boston, MA
Use the Variable Viewer to check this line?
NEVER use '0' and 'o' together :x
Code:
Case ListOfNamesArray(0)\ButtonGadgetNumber To ListOfNamesArray(ArraySize(ListOfNamesArray()))\ButtonGadgetNumber

_________________
To understand recursion, you must first understand recursion. ~ unknown
I never make stupid mistakes. Only very, very clever ones. ~ John Peel


Top
 Profile  
 
 Post subject: Re: Dynamic creation of gadgets - PB Event Gadget to detect.
PostPosted: Sun Mar 11, 2012 5:46 pm 
Offline
User
User

Joined: Tue Jan 01, 2008 4:35 pm
Posts: 17
Location: UK
Thank you for the speedy response

Good point about o and 0 ... it was "n" but changed it because I already had a case using "n"... so was clutching at straws to see if it was that ... but it wasn't

OK I added "Debug EventGadget()" after the "EndSelect"... and also ran variable viewer...

ButtonGadgetNumber in ListOfNamesArray() = 31682544
Debug output for EventGadget = 31682544

...so one and the same...


Top
 Profile  
 
 Post subject: Re: Dynamic creation of gadgets - PB Event Gadget to detect.
PostPosted: Sun Mar 11, 2012 6:06 pm 
Online
Addict
Addict
User avatar

Joined: Wed Dec 23, 2009 10:14 pm
Posts: 1386
Location: Boston, MA
You Debug a variable that stored EventGadget(), right?
Otherwise, you are calling it twice.


Top
 Profile  
 
 Post subject: Re: Dynamic creation of gadgets - PB Event Gadget to detect.
PostPosted: Sun Mar 11, 2012 6:16 pm 
Offline
User
User

Joined: Tue Jan 01, 2008 4:35 pm
Posts: 17
Location: UK
Yes I am. OK I wasnt but just changed it to stick the event in a variable then select against that... with the same result
The "case" for the dynamic buttons sometimes fires... and usually not... so intermittent
Getting to the point where I think I need to re-design it... a series of radio buttons with a single "send" button should do it :)


Top
 Profile  
 
 Post subject: Re: Dynamic creation of gadgets - PB Event Gadget to detect.
PostPosted: Sun Mar 11, 2012 6:41 pm 
Online
Addict
Addict
User avatar

Joined: Wed Dec 23, 2009 10:14 pm
Posts: 1386
Location: Boston, MA
Ok, I am getting the sense that you are starting with too much complexity.
Create a small example of your GUI with an Event Loop that runs correctly.
Then wrap the gadget elements in an array of structure and replace the Event Loop variables carefully.
Here is the Structure I use to automatically generate a GUI based on a DataSection entry.
Code:
Structure GadgetInfo ;- GadgetInfo
  Type.i        ; PB Gadget Type
  Index.i       ; Show/Enabled = 1, Hidden = -1, Disabled = 0
                ; This also is a running count of all gadgets loaded in a window
  Item.i        ; Field/Item for combination gadgets like; Panel, StatusBar
  id.i          ; PB id
  X.i           ; X position
  Y.i           ; Y position
  Wd.i          ; Width
  Ht.i          ; Height
  LL.i          ; LockLeft
  LT.i          ; LockTop
  LR.i          ; LockRight
  LB.i          ; LockBottom
  Txt.s         ; Main text
  TT.s          ; Tooltip text
  Flags.i       ; Flags
  Attr.i        ; Attribute
  hnd.i         ; Windows handle
  FC.i          ; Foreground Color
  BC.i          ; Background Color
  Font.i        ; Font id, name and size defined in structure FontInfo
                ; Additional placeholders for gadget info...
  imgNr.i       ; Image number in myImages()
  Min.i         ; Minimum
  Max.i         ; Maximum
  Lng.i         ; Length
  pID.i         ; Parent Gadget ID
EndStructure


Top
 Profile  
 
 Post subject: Re: Dynamic creation of gadgets - PB Event Gadget to detect.
PostPosted: Sun Mar 11, 2012 7:46 pm 
Offline
User
User

Joined: Tue Jan 01, 2008 4:35 pm
Posts: 17
Location: UK
OK have re-built a stand-alone version that I am trying to achieve... so it can be run anywhere (current one pulls data from a database etc etc) so this uses random numbers to provide the array sizes

Try it... the top button will work, several presses confirm that. Some other buttons may work but unlikely. Then click the bottom button (the refresh) which re-does the array... and no button will work!

Any thoughts?

Thanks

Simon

Code:
Structure ListOfNamesStructure
  Identifier.s
  NameGadgetNumber.i
  ButtonGadgetNumber.i
EndStructure
Global Dim ListOfGadgetArray.ListOfNamesStructure(0)

Enumeration
  #Window_0
EndEnumeration

Enumeration
  #ScrollingArea
  #ReloadButton
EndEnumeration

Procedure CreateALoadOfGadgets()
  NumberOfGadgets = Random(50)+100
  ReDim ListOfGadgetArray(NumberOfGadgets)
  SetGadgetAttribute(#ScrollingArea,#PB_ScrollArea_InnerHeight,(ArraySize(ListOfGadgetArray())*40)+40)
 
  OpenGadgetList(#ScrollingArea)
  For n = 0 To ArraySize(ListOfGadgetArray())
    ListOfGadgetArray(n)\Identifier = "This Is Button "+Str(n)
    ListOfGadgetArray(n)\ButtonGadgetNumber = ButtonGadget(#PB_Any,0,(n*40)+10,50,20,"Press Me")
    ListOfGadgetArray(n)\NameGadgetNumber = TextGadget(#PB_Any,60,n*40,GadgetWidth(#ScrollingArea)-100,40,ListOfGadgetArray(n)\Identifier)
  Next
  CloseGadgetList()
EndProcedure

Procedure DestroyCreatedGadgets()
  For n = 0 To ArraySize(ListOfGadgetArray())
    FreeGadget(ListOfGadgetArray(n)\ButtonGadgetNumber)
    FreeGadget(ListOfGadgetArray(n)\NameGadgetNumber)
  Next
  ReDim ListOfGadgetArray(0)
  SetGadgetAttribute(#ScrollingArea,#PB_ScrollArea_InnerHeight,1) 
EndProcedure

Procedure OpenDisplayWindow()
  If OpenWindow(#Window_0, 0, 0, 800, 400, "Blah",#PB_Window_BorderLess | #PB_Window_ScreenCentered | #PB_Window_Maximize )
    ButtonGadget(#ReloadButton,0,WindowHeight(#Window_0)-100,WindowWidth(#Window_0),100,"Reload Array")
    ScrollAreaGadget(#ScrollingArea,10,10,WindowWidth(#Window_0)-20,WindowHeight(#Window_0)-150,WindowWidth(#Window_0)-50,1,100)
    CloseGadgetList()
  EndIf
EndProcedure


;- At Runtime
OpenDisplayWindow()
CreateALoadOfGadgets()

;-Loop
Repeat
  Event = WaitWindowEvent(100)
  Select Event
    Case #PB_Event_Gadget
      EventGadgetHappened = EventGadget()
      Select EventGadgetHappened
        Case #ReloadButton
          DestroyCreatedGadgets()
          CreateALoadOfGadgets()
        Case ListOfGadgetArray(0)\ButtonGadgetNumber To ListOfGadgetArray(ArraySize(ListOfGadgetArray()))\ButtonGadgetNumber
          For n = 0 To ArraySize(ListOfGadgetArray())
            If ListOfGadgetArray(n)\ButtonGadgetNumber = EventGadgetHappened
              Break
            EndIf
          Next
          Debug "Button Pressed :" + ListOfGadgetArray(n)\Identifier
      EndSelect
  EndSelect
ForEver


Top
 Profile  
 
 Post subject: Re: Dynamic creation of gadgets - PB Event Gadget to detect.
PostPosted: Sun Mar 11, 2012 7:58 pm 
Offline
User
User

Joined: Tue Jan 01, 2008 4:35 pm
Posts: 17
Location: UK
Maybe bad form to reply to ones own post... but...
I added the following into the select...
Code:
        Default
          For n = 0 To ArraySize(ListOfGadgetArray())
            If ListOfGadgetArray(n)\ButtonGadgetNumber = EventGadgetHappened
              Break
            EndIf
          Next
          Debug "Default: Button Pressed :" + ListOfGadgetArray(n)\Identifier

To make sure I can catch anything. Only problem is if you now scroll with the mouse scroll it dies with "[ERROR] Array index out of bounds"


Top
 Profile  
 
 Post subject: Re: Dynamic creation of gadgets - PB Event Gadget to detect.
PostPosted: Sun Mar 11, 2012 10:01 pm 
Offline
Addict
Addict
User avatar

Joined: Fri Sep 21, 2007 5:52 am
Posts: 2488
Location: New Zealand
it's easier to use a map
I'm assuming that you want to associate a button with another gadget

Code:
Structure ListOfNamesStructure
  Identifier.s
  NameGadgetNumber.i
EndStructure

Global NewMap MapGadgets.ListOfNamesStructure()

Enumeration
  #Window_0
EndEnumeration

Enumeration
  #ScrollingArea
  #ReloadButton
EndEnumeration

Procedure CreateALoadOfGadgets()
  NumberOfGadgets = Random(50)+100
 
  SetGadgetAttribute(#ScrollingArea,#PB_ScrollArea_InnerHeight,(NumberOfGadgets*40)+40)
 
  OpenGadgetList(#ScrollingArea)
  For n = 0 To NumberOfGadgets-1
    gad = TextGadget(#PB_Any,60,n*40,GadgetWidth(#ScrollingArea)-100,40,"This Is Button "+Str(n))
    but =  ButtonGadget(#PB_Any,0,(n*40)+10,50,20,"Press Me")
    mapGadgets(Str(but))\Identifier = "This Is Button "+Str(n)
    mapGadgets(Str(but))\NameGadgetNumber = gad ;Use that if you need to update associated gadget
   
  Next
  CloseGadgetList()
EndProcedure

Procedure DestroyCreatedGadgets()
  ForEach mapGadgets()
    If mapgadgets()
      FreeGadget(mapgadgets())
    EndIf
  Next
  ClearMap(mapGadgets())
 
    SetGadgetAttribute(#ScrollingArea,#PB_ScrollArea_InnerHeight,1) 
EndProcedure

Procedure OpenDisplayWindow()
  If OpenWindow(#Window_0, 0, 0, 800, 400, "Blah",#PB_Window_BorderLess | #PB_Window_ScreenCentered | #PB_Window_Maximize )
    ButtonGadget(#ReloadButton,0,WindowHeight(#Window_0)-100,WindowWidth(#Window_0),100,"Reload Array")
    ScrollAreaGadget(#ScrollingArea,10,10,WindowWidth(#Window_0)-20,WindowHeight(#Window_0)-150,WindowWidth(#Window_0)-50,1,100)
    CloseGadgetList()
  EndIf
EndProcedure


;- At Runtime
OpenDisplayWindow()
CreateALoadOfGadgets()

;-Loop
Repeat
  Event = WaitWindowEvent(100)
  Select Event
    Case #PB_Event_Gadget
      EventGadgetHappened = EventGadget()
      Select EventGadgetHappened
        Case #ReloadButton
          DestroyCreatedGadgets()
          CreateALoadOfGadgets()
        Default
          If FindMapElement(MapGadgets(),Str(EventGadgetHappened))
            Debug "Button Pressed :" + MapGadgets(Str(EventGadgetHappened))\Identifier
          EndIf 
      EndSelect
  EndSelect
ForEver


Top
 Profile  
 
 Post subject: Re: Dynamic creation of gadgets - PB Event Gadget to detect.
PostPosted: Sun Mar 11, 2012 10:12 pm 
Offline
User
User

Joined: Tue Jan 01, 2008 4:35 pm
Posts: 17
Location: UK
Hi Idle

Thanks for joining in... never used a map but see what you are doing there, so happy to change my code to this way of doing things... but...
click the big bottom button... to reload some new text/gadgets... and suddenly the new ones no longer function...
this means you can only fire it once... but I need this to do something when you click the smaller buttons, and then it will reload some new information with new buttons to press with a different outcome


Top
 Profile  
 
 Post subject: Re: Dynamic creation of gadgets - PB Event Gadget to detect.
PostPosted: Sun Mar 11, 2012 10:19 pm 
Offline
Addict
Addict
User avatar

Joined: Fri Sep 21, 2007 5:52 am
Posts: 2488
Location: New Zealand
Wasn't really paying attention
No problem to fix but do you need to associate the other gadgets to the button
like do you need to update the adjacent gadgets to the button ?

no association to adjacent gadget
Code:
Structure ListOfNamesStructure
  Identifier.s
  GadgetNumber.i
     
EndStructure

Global NewMap MapGadgets.ListOfNamesStructure()

Enumeration
  #Window_0
EndEnumeration

Enumeration
  #ScrollingArea
  #ReloadButton
EndEnumeration

Procedure CreateALoadOfGadgets()
  NumberOfGadgets = Random(50)+100
 
  SetGadgetAttribute(#ScrollingArea,#PB_ScrollArea_InnerHeight,(NumberOfGadgets*40)+40)
 
  OpenGadgetList(#ScrollingArea)
  For n = 0 To NumberOfGadgets-1
    gad = TextGadget(#PB_Any,60,n*40,GadgetWidth(#ScrollingArea)-100,40,"This Is Button "+Str(n))
    but =  ButtonGadget(#PB_Any,0,(n*40)+10,50,20,"Press Me")
    mapGadgets(Str(but))\Identifier = "This Is Button "+Str(n)
    mapGadgets(Str(but))\GadgetNumber = but
    mapGadgets(Str(gad))\GadgetNumber = gad
   Next
  CloseGadgetList()
EndProcedure

Procedure DestroyCreatedGadgets()
  ForEach mapGadgets()
    If mapgadgets()
      tgad= mapgadgets()\GadgetNumber
      FreeGadget(tgad)
    EndIf
  Next
  ClearMap(mapGadgets())
 
    SetGadgetAttribute(#ScrollingArea,#PB_ScrollArea_InnerHeight,1) 
EndProcedure

Procedure OpenDisplayWindow()
  If OpenWindow(#Window_0, 0, 0, 800, 400, "Blah",#PB_Window_BorderLess | #PB_Window_ScreenCentered | #PB_Window_Maximize )
    ButtonGadget(#ReloadButton,0,WindowHeight(#Window_0)-100,WindowWidth(#Window_0),100,"Reload Array")
    ScrollAreaGadget(#ScrollingArea,10,10,WindowWidth(#Window_0)-20,WindowHeight(#Window_0)-150,WindowWidth(#Window_0)-50,1,100)
    CloseGadgetList()
  EndIf
EndProcedure


;- At Runtime
OpenDisplayWindow()
CreateALoadOfGadgets()

;-Loop
Repeat
  Event = WaitWindowEvent(100)
  Select Event
    Case #PB_Event_Gadget
      EventGadgetHappened = EventGadget()
      Select EventGadgetHappened
        Case #ReloadButton
          DestroyCreatedGadgets()
          CreateALoadOfGadgets()
        Default
          If FindMapElement(MapGadgets(),Str(EventGadgetHappened))
            Debug "Button Pressed :" + MapGadgets(Str(EventGadgetHappened))\Identifier
          EndIf 
      EndSelect
  EndSelect
ForEver


Top
 Profile  
 
 Post subject: Re: Dynamic creation of gadgets - PB Event Gadget to detect.
PostPosted: Sun Mar 11, 2012 10:29 pm 
Offline
User
User

Joined: Tue Jan 01, 2008 4:35 pm
Posts: 17
Location: UK
No worries ... wasn't quite sure how to explain the issue so my fault :)

ok basically the refresh button is there to simulate what I am doing

I generate a load of buttongadgets and textgadgets, which I then let the user press one of the buttons
Once pressed, the user is taken to another screen, with the value of the button they pressed passed through to be used elsewhere
Once on the new screen all those button and text gadgets I generated are removed, because next time I generate them I could be creating more or less... and want to make sure I create the gadgets nice and clean

Hope that helps, and thanks for the help

EDIT: Ok I misunderstood your question... no I won't change the labels but will remove those as well at the same time i destroy the buttons, but read the values in each time from a database


Top
 Profile  
 
 Post subject: Re: Dynamic creation of gadgets - PB Event Gadget to detect.
PostPosted: Sun Mar 11, 2012 10:50 pm 
Offline
Addict
Addict
User avatar

Joined: Fri Sep 21, 2007 5:52 am
Posts: 2488
Location: New Zealand
You do realize that you can associate data with gadgets
so you could quite easily do it like this also

SetGadgetData(#Gadget, Value)
and then retrive it with
GetGadgetData(#gadget)

while that data item is simply a integer you can store a reference to a string or structure
but you'd need to store the string and structure somewhere else
like in a linked list or allocated on the heap

either way will work
Code:
 
Structure MyDataStructure
  gadget.i
  Sometext.s
  SomeValue.i
EndStructure

Global NewList GadgetData.MyDataStructure()

Enumeration
  #Window_0
EndEnumeration

Enumeration
  #ScrollingArea
  #ReloadButton
EndEnumeration

Procedure CreateALoadOfGadgets()
  NumberOfGadgets = Random(50)+100
 
  SetGadgetAttribute(#ScrollingArea,#PB_ScrollArea_InnerHeight,(NumberOfGadgets*40)+40)
 
  OpenGadgetList(#ScrollingArea)
  For n = 0 To NumberOfGadgets-1
    gad = TextGadget(#PB_Any,60,n*40,GadgetWidth(#ScrollingArea)-100,40,"This Is Button "+Str(n))
    but =  ButtonGadget(#PB_Any,0,(n*40)+10,50,20,"Press Me")
    AddElement(GadgetData())
    gadgetData()\Sometext = "This is Button"+Str(n)
    GadgetData()\SomeValue = n
    GadgetData()\gadget = but
    SetGadgetData(but,@GadgetData())
    AddElement(GadgetData())
    GadgetData()\gadget = gad
   Next
  CloseGadgetList()
EndProcedure

Procedure DestroyCreatedGadgets()
  ForEach Gadgetdata()
    FreeGadget(GadgetData()\gadget)
  Next
  ClearList(GadgetData())
 
    SetGadgetAttribute(#ScrollingArea,#PB_ScrollArea_InnerHeight,1) 
EndProcedure

Procedure OpenDisplayWindow()
  If OpenWindow(#Window_0, 0, 0, 800, 400, "Blah",#PB_Window_BorderLess | #PB_Window_ScreenCentered | #PB_Window_Maximize )
    ButtonGadget(#ReloadButton,0,WindowHeight(#Window_0)-100,WindowWidth(#Window_0),100,"Reload Array")
    ScrollAreaGadget(#ScrollingArea,10,10,WindowWidth(#Window_0)-20,WindowHeight(#Window_0)-150,WindowWidth(#Window_0)-50,1,100)
    CloseGadgetList()
  EndIf
EndProcedure

 

;- At Runtime
OpenDisplayWindow()
CreateALoadOfGadgets()

;-Loop
Repeat
  Event = WaitWindowEvent(100)
  Select Event
    Case #PB_Event_Gadget
      EventGadgetHappened = EventGadget()
      Select EventGadgetHappened
        Case #ReloadButton
          DestroyCreatedGadgets()
          CreateALoadOfGadgets()
        Default
          gad = GetGadgetData(EventGadgetHappened)
          If gad
            ChangeCurrentElement(GadgetData(),gad)
            Debug "Button Pressed :" + GadgetData()\Sometext
          EndIf 
      EndSelect
  EndSelect
ForEver


Top
 Profile  
 
 Post subject: Re: Dynamic creation of gadgets - PB Event Gadget to detect.
PostPosted: Sun Mar 11, 2012 11:16 pm 
Offline
User
User

Joined: Tue Jan 01, 2008 4:35 pm
Posts: 17
Location: UK
I was totally unaware you could do that with the gadget data :)
Will try using that on my next project

Thank you for your code - will use that to solve the issue I am having!

Thanks

Simon


Top
 Profile  
 
 Post subject: Re: Dynamic creation of gadgets - PB Event Gadget to detect.
PostPosted: Mon Mar 12, 2012 8:59 pm 
Offline
Addict
Addict
User avatar

Joined: Mon Jul 25, 2005 3:51 pm
Posts: 2401
Location: Utah, USA
sdebenham wrote:
OK have re-built a stand-alone version that I am trying to achieve... so it can be run anywhere (current one pulls data from a database etc etc) so this uses random numbers to provide the array sizes

Try it... the top button will work, several presses confirm that. Some other buttons may work but unlikely. Then click the bottom button (the refresh) which re-does the array... and no button will work!

Any thoughts?


Here are changes to make your code sample work:
Code:
;-Loop
Repeat
  event = WaitWindowEvent(100)
  Select event
    Case #PB_Event_Gadget
      EventGadgetHappened = EventGadget()
      Select EventGadgetHappened
        Case #ReloadButton
          DestroyCreatedGadgets()
          CreateALoadOfGadgets()
        ; Case ListOfGadgetArray(0)\ButtonGadgetNumber To ListOfGadgetArray(ArraySize(ListOfGadgetArray()))\ButtonGadgetNumber
         ; For n = 0 To ArraySize(ListOfGadgetArray())
            ; If ListOfGadgetArray(n)\ButtonGadgetNumber = EventGadgetHappened
              ; Break
            ; EndIf
          ; Next
          ; Debug "Button Pressed :" + ListOfGadgetArray(n)\Identifier
        Case #ScrollingArea
         
        Default
          For n = 0 To ArraySize(ListOfGadgetArray())
            If ListOfGadgetArray(n)\ButtonGadgetNumber = EventGadgetHappened
              Break
            EndIf
          Next
          Debug "Default: Button Pressed :" + ListOfGadgetArray(n)\Identifier
      EndSelect
  EndSelect
ForEver


The changes involved two things. First, you didn't account for events from the ScrollAreaGadget. Second, the case statement for dealing with the buttons had an unreliable range selection:
Code:
Case ListOfGadgetArray(0)\ButtonGadgetNumber To ListOfGadgetArray(ArraySize(ListOfGadgetArray()))\ButtonGadgetNumber
  ;This range is not guaranteed to include all of the buttons because their numbers can be non-sequential.
  ;This means you can't specify their range as first -> last.  You either have to look at each individually, or use the default case after all the known gadgets have been accounted for.
  ;You have a third option but it would involve keeping track of the minimum and maximum gadget#'s after each creation.  That could be messy.

_________________
Image


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: Neil and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye