[Gambas-user] Menu shortcut keys
Gianluigi
bagonergi at gmail.com
Sat Apr 9 22:56:54 CEST 2022
Il giorno sab 9 apr 2022 alle ore 18:25 Charlie Ogier <charlie at cogier.com>
ha scritto:
> Hi,
>
> I am trying to program a shortcut key for a menu item but all I seem to
> be able to do is click on [Ctrl], [Shift] or [Alt]. I can't see away to
> add a letter. Am I missing something?
>
> Thanks,
>
> Charlie
>
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>
Hi Charlie,
do you mean something like this?
'---------------------------------------------
Public Sub Form_Open()
Dim hMenu, hSubMenu As Menu
Dim i As Integer
Dim aSubMenu As String[] = ["New", "Open", "Save", "Quit"]
Dim s As String = "file-"
Dim sAction As String
With hMenu = New Menu(FMain)
.Caption = "File"
End With
For i = 0 To aSubMenu.Max
sAction = s & Lower(aSubMenu[i])
With hSubMenu = New Menu(hMenu) As "SubMenu"
.Action = sAction
Action[sAction].Shortcut = "Ctrl+" & Left(aSubMenu[i])
.Caption = aSubMenu[i]
.Name = aSubMenu[i]
End With
Next
End
Public Sub Action_Activate(sKey As String) As Boolean
Select Case sKey
Case "file-new"
Print "Create new file"
Case "file-open"
Print "Open existing file"
Case "file-save"
Print "Save current file"
Case "file-quit"
Me.Close
End Select
End
'-----------------------------------------------------
Regards
Gianluigi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20220409/caf27909/attachment.htm>
More information about the User
mailing list