coco2 wrote: Sat Mar 07, 2026 8:18 am
When I do this:
Code: Select all
Enumeration Events
#EventMainKeyboardCtrlN
#EventMainKeyboardCtrlO
#EventMainKeyboardCtrlQ
#EventMainKeyboardESC
#EventMainKeyboardF5
#EventNewKeyboardReturn
#EventNewSectionKeyboardReturn = 10
EndEnumeration
it works, but when I delete the "= 10" it fails.
The constant enumeration named "Events" should be deleted if an enumeration with the same name already exists, as its values would be appended to the existing ones.
To name a constant enumeration, its values must be sequential menu item IDs, so it should be named something like “Enumeration MenuItemID”.
Code: Select all
Enumeration ;MenuItemID
#EventMainKeyboardCtrlN
#EventMainKeyboardCtrlO
#EventMainKeyboardCtrlQ
#EventMainKeyboardESC
#EventMainKeyboardF5
#EventNewKeyboardReturn
#EventNewSectionKeyboardReturn = 10
EndEnumeration
#WindowMain = 0
#WindowMain1 = 1
If OpenWindow(#WindowMain, 200, 200, 200, 100, "")
OpenWindow(#WindowMain1, 200, 200, 200, 100, "", #PB_Window_ScreenCentered)
AddKeyboardShortcut(#WindowMain, #PB_Shortcut_Control | #PB_Shortcut_N, #EventMainKeyboardCtrlN)
AddKeyboardShortcut(#WindowMain, #PB_Shortcut_Control | #PB_Shortcut_O, #EventMainKeyboardCtrlO)
AddKeyboardShortcut(#WindowMain, #PB_Shortcut_Control | #PB_Shortcut_Q, #EventMainKeyboardCtrlQ)
AddKeyboardShortcut(#WindowMain, #PB_Shortcut_Escape, #EventMainKeyboardESC)
AddKeyboardShortcut(#WindowMain, #PB_Shortcut_F5, #EventMainKeyboardF5)
AddKeyboardShortcut(#WindowMain, #PB_Shortcut_Return, #EventNewKeyboardReturn)
AddKeyboardShortcut(#WindowMain1, #PB_Shortcut_Return, #EventNewSectionKeyboardReturn) ;The same key must be assigned to a different window.
Repeat
Select WaitWindowEvent()
Case #PB_Event_Menu
Select EventMenu()
Case #EventMainKeyboardCtrlN
Debug "#EventMainKeyboardCtrlN"
Case #EventMainKeyboardCtrlO
Debug "#EventMainKeyboardCtrlO"
Case #EventMainKeyboardCtrlQ
Debug "#EventMainKeyboardCtrlQ"
Case #EventMainKeyboardESC
Debug "#EventMainKeyboardESC"
Case #EventMainKeyboardF5
Debug "#EventMainKeyboardF5"
Case #EventNewKeyboardReturn
Debug "#EventNewKeyboardReturn"
Case #EventNewSectionKeyboardReturn
Debug "#EventNewSectionKeyboardReturn"
EndSelect
Case #PB_Event_CloseWindow
End
EndSelect
ForEver
EndIf