[Gambas-user] ToggleButton issue

Bruce Steers bsteers4 at gmail.com
Sat Feb 19 12:13:19 CET 2022


Using Action[] accepts regex so you can give the TogleButtons action
strings like "setup1" , "setup2" "setup3" etc

Then call
Action["setup*"].Enabled = False

BruceS

On Sat, 19 Feb 2022 at 10:16, Charlie Ogier <charlie at cogier.com> wrote:

> 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 ]----
>
>
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20220219/1c0c7647/attachment.htm>


More information about the User mailing list