Answered by:
What am I doing wrong with LDcontrols.checkbox extensions?

Question
-
Hi All
Been trying to learn the ldcontrols checkbox extensions, and I am not sure what I am doing wrong, but when I make the GW to start over the event trigger for when a checkbox is changed is no longer enabled.
Here is the little learning sample I am trying for myself, do apologize if it is overly simple ( see below).
When I click on the "Start over " button, the gw restarted, but the event trigger for checkbox no longer worked, however, the event trigger for buttonclicked still works.
Please advice what I am doing wrong?
Regards
creatgw()
Sub creatgw
GraphicsWindow.Show()
gwchkbox[1] ="Box 1"
gwchkbox[2] ="Box 2"
gwchkbox[3] ="Box 3"
chekbox[1] = LDControls.AddCheckBox(gwchkbox[1])
chekbox[2] = LDControls.AddCheckBox(gwchkbox[2])
chekbox[3] = LDControls.AddCheckBox(gwchkbox[3])
gwbutton[1] = Controls.AddButton("start over", 20,40 )
Controls.Move(chekbox[1], 0, 10)
Controls.Move(chekbox[2], 60, 10)
Controls.Move(chekbox[3], 120, 10)
LDControls.CheckBoxChanged = response
Controls.ButtonClicked = onbuttonclicked
EndSub
Sub response
If LDControls.LastCheckBox ="Control1" and LDControls.CheckBoxGetState(chekbox[1]) = "True" Then
TextWindow.WriteLine("You have ticked " + gwchkbox[1])
ElseIf LDControls.LastCheckBox ="Control2" and LDControls.CheckBoxGetState(chekbox[2]) = "True" Then
TextWindow.WriteLine("You have ticked " + gwchkbox[2])
ElseIf LDControls.LastCheckBox ="Control3" and LDControls.CheckBoxGetState(chekbox[3]) = "True" Then
TextWindow.WriteLine("You have ticked " + gwchkbox[3])
EndIf
EndSub
Sub onbuttonclicked
If Controls.LastClickedButton = gwbutton[1] Then
creatgw()
EndIf
EndSub
- Edited by Joe.wAU Saturday, September 28, 2019 9:42 AM
Saturday, September 28, 2019 9:41 AM
Answers
-
That's because, if you call 'creatgw()' the next time, the GW will be rebuild and internal numbering/indexing of 'Control#' and 'Button#' continues.
So on every button click (-> Sub creatgw), the internal # of "Control#" will increase by +3 and # of "Button#" will increase by +1. So that you'll have "Control4", "Control5" and "Control6" for the CheckBoxes and "Button2" for the button, aso. Then -next time- "Control7", "Control8", "Control9" and "Button3" etc.
- Proposed as answer by litdev Sunday, September 29, 2019 1:17 AM
- Marked as answer by WhTurner33Editor Monday, November 4, 2019 11:59 AM
Saturday, September 28, 2019 8:05 PMAnswerer
All replies
-
That's because, if you call 'creatgw()' the next time, the GW will be rebuild and internal numbering/indexing of 'Control#' and 'Button#' continues.
So on every button click (-> Sub creatgw), the internal # of "Control#" will increase by +3 and # of "Button#" will increase by +1. So that you'll have "Control4", "Control5" and "Control6" for the CheckBoxes and "Button2" for the button, aso. Then -next time- "Control7", "Control8", "Control9" and "Button3" etc.
- Proposed as answer by litdev Sunday, September 29, 2019 1:17 AM
- Marked as answer by WhTurner33Editor Monday, November 4, 2019 11:59 AM
Saturday, September 28, 2019 8:05 PMAnswerer -
So, is there anyway to reset them back or stop them from increasing?
If so, how would you do it?
Also, thanks for answering.
Regards
Sunday, September 29, 2019 1:38 AM -
To reset the boxes to unchecked use:
Sub onbuttonclicked If Controls.LastClickedButton = gwbutton[1] Then cleargw() ''<<<<<<<<<<< EndIf EndSub sub cleargw LDControls.CheckBoxState(chekbox[1],"False") LDControls.CheckBoxState(chekbox[2],"False") LDControls.CheckBoxState(chekbox[3],"False") EndSub
Jan [ WhTurner ] The Netherlands
Monday, September 30, 2019 10:58 AMAnswerer