[Gambas-user] Creating Actions at runtime

Gianluigi bagonergi at gmail.com
Fri Sep 21 09:49:27 CEST 2018


Il giorno ven 21 set 2018 alle ore 04:20 Me <adamnt42 at gmail.com> ha scritto:

> I am trying to add a new menu at runtime. That works fine and it gets
> added into the Action.List. However, the menu has a shortcut and that
> doesn't get added into the shortcuts managed by Action.Configure.
> The code is pretty straightforward:
>         Dim TestMenu as Menu
>
>         TestMenu = New Menu(mnuFile)
>         With TestMenu
>                 .Name="mnuTest"
>                 .Caption="Test Action"
>                 .ShortCut="CTRL+T"
>                 Action="MENU.Test"
>         End With
>
> Any clues?
> b
> --
> Me <adamnt42 at gmail.com>
>
>
Maybe by writing it this way:

Public Sub Form_Open()

  Dim TestMenu As Menu

  TestMenu = New Menu(mnuFile)
  With TestMenu
    .Name = "mnuTest"
    .Caption = "Test Action"
    '.ShortCut = "CTRL+T"
    .Action = "menu-test"
  End With
  Action["menu-test"].Shortcut = "CTRL+T"

End

Public Sub Action_Activate(sKey As String) As Boolean

  Select Case sKey
    Case "menu-test"
      Print "menu test"
  End Select

End

Regards
Gianluigi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gambas-basic.org/pipermail/user/attachments/20180921/75c08b54/attachment.html>


More information about the User mailing list