Binding keyboard shortcuts

Just starting out? Need help? Post your questions and find answers here.
User avatar
marcoagpinto
Addict
Addict
Posts: 1048
Joined: Sun Mar 10, 2013 3:01 pm
Location: Portugal
Contact:

Binding keyboard shortcuts

Post by marcoagpinto »

Hello!

Code: Select all

    ; Add keyboard shortcuts
    AddKeyboardShortcut(#WINDOW_ADD_EDIT,#PB_Shortcut_Escape,1000)    
    AddKeyboardShortcut(#WINDOW_ADD_EDIT,#PB_Shortcut_Return,1003)    
    AddKeyboardShortcut(#WINDOW_ADD_EDIT,#PB_Shortcut_F1,1004)  
How do I use a Bind command for keyboard shortcuts?

I already have Bindings to gadgets:

Code: Select all

    BindGadgetEvent(#TEXTBOX_WINDOW_ADD_EDIT_WORD, @process_pfx_sfx_update_word(),#PB_EventType_Change) ; Current word
    BindGadgetEvent(#BUTTON_ADD_EDIT_OKAY, @process_pfx_sfx_update_word_okay(),#PB_EventType_LeftClick) ; Okay
    BindGadgetEvent(#BUTTON_ADD_EDIT_CANCEL, @process_pfx_sfx_update_word_cancel(),#PB_EventType_LeftClick) ; Cancel
But I don't know how to do the same for the shortcuts above.

Thank you!
wombats
Enthusiast
Enthusiast
Posts: 717
Joined: Thu Dec 29, 2011 5:03 pm

Re: Binding keyboard shortcuts

Post by wombats »

Code: Select all

Enumeration
  #Window
  #CtrlAShortcut
  #ShiftBShortcut
EndEnumeration

Procedure OnCtrlA()
  MessageRequester("", "Ctrl + A pressed")
EndProcedure

Procedure OnShiftB()
  MessageRequester("", "Shift + B pressed")
EndProcedure

OpenWindow(#Window, 0, 0, 320, 240, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

AddKeyboardShortcut(#Window, #PB_Shortcut_A | #PB_Shortcut_Control, #CtrlAShortcut)
AddKeyboardShortcut(#Window, #PB_Shortcut_B | #PB_Shortcut_Shift, #ShiftBShortcut)

BindEvent(#PB_Event_Menu, @OnCtrlA(), #Window, #CtrlAShortcut)
BindEvent(#PB_Event_Menu, @OnShiftB(), #Window, #ShiftBShortcut)

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
User avatar
marcoagpinto
Addict
Addict
Posts: 1048
Joined: Sun Mar 10, 2013 3:01 pm
Location: Portugal
Contact:

Re: Binding keyboard shortcuts

Post by marcoagpinto »

It is working!!!!

Thank you!
Post Reply