[Gambas-user] ToggleButton issue
Charlie Ogier
charlie at cogier.com
Sat Feb 19 10:53:44 CET 2022
The idea is to have a collection of ToggleButtons that I can Enable or
Disable with a single Action command.
Here is an example of this working with both Buttons and ToggleButtons
My question is why when you click a single ToggleButton all the other
Togglebuttons Values change. This does not happen with Buttons.
'*******************************************************
But As Button
TB As ToggleButton
VBox1 As VBox
Public Sub Form_Open()
Dim iLoop As Integer
With Me
.Arrangement = Arrange.Horizontal
.Padding = 5
.W = 350
.H = 200
End With
VBox1 = New VBox(Me)
VBox1.Expand = True
For iLoop = 0 To 6
With But = New Button(VBox1) As "AllButtons"
.H = 28
.W = 100
If iLoop = 6 Then
.Text = "Click to &En/Disable"
.Font.Bold = True
.Tag = "!"
Else
.Text = "&Click Button " & Str(iLoop + 1)
.Picture = Picture["icon:/22/right"]
.Action = "setupButtons" 'This is the line DOES NOT causes a
problem
Endif
End With
Next
VBox1 = New VBox(Me)
VBox1.Expand = True
For iLoop = 0 To 6
With TB = New ToggleButton(VBox1) As "AllTBs"
.H = 28
.W = 100
If iLoop = 6 Then
.Text = "Click to En/&Disable"
.Font.Bold = True
.Tag = "!"
Else
.Text = "&Click ToggleButton " & Str(iLoop + 1)
.Picture = Picture["icon:/22/right"]
.Action = "setupTBs" ''This is the line that causes the problem
End If
End With
Next
End
Public Sub AllButtons_Click()
If Last.Tag = "!" Then Action["setupButtons"].enabled = Not
Action["setupButtons"].enabled
End
Public Sub AllTBs_Click()
If Last.Tag = "!" Then Action["setupTBs"].enabled = Not
Action["setupTBs"].enabled
End
'*******************************************************
On 19/02/2022 06:25, Fabien Bodard wrote:
> This is the way action act 😊.
>
> Don't give the same name (or do not use action)
>
> Maybe you can share your idea so we can help to find the best way to
> achieve your goal
>
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
More information about the User
mailing list