Page 1 of 1

Keys

Posted: Fri Aug 26, 2005 1:39 am
by sk8terboi
If i am in a editor gadget, how can i disable a keys? Like backspace. Could i have an example.
Thanks so much! :wink:

Posted: Fri Aug 26, 2005 10:56 am
by fweil
You should use AddKeyboardShortcut() to catch and process a specific key behaviour.

Posted: Fri Aug 26, 2005 11:05 pm
by sk8terboi
I meant disable not add a shortcut. Like so delete won't work.

Posted: Fri Aug 26, 2005 11:44 pm
by fweil
I meant something like that :

Code: Select all

Enumeration
  #Window_Main
  #Gadget_Editor
EndEnumeration

  WindowWidth = 640
  WindowHeight = 480
  If OpenWindow(#Window_Main, 0, 0, WindowWidth, WindowHeight, #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered, "MyWindow")
      AddKeyboardShortcut(#Window_Main, #PB_Shortcut_Escape, #PB_Shortcut_Escape)
      AddKeyboardShortcut(#Window_Main, #PB_Shortcut_Delete, #PB_Shortcut_Delete)
      If CreateGadgetList(WindowID(#Window_Main))
          EditorGadget(#Gadget_Editor, 10, 10, 620, 460, "")
      EndIf
      Quit = #False
      Repeat
        Select WaitWindowEvent()
          Case #PB_Event_CloseWindow
            Quit = #True
          Case #PB_Event_Menu
            Select EventMenuID()
              Case #PB_Shortcut_Escape
                Quit = #True
              Case #PB_Shortcut_Delete
                MessageRequester("Warning", "Delete key is not usable here")
            EndSelect
        EndSelect
      Until Quit
  EndIf
End
This disables Delete key ... but it will work easy only if you want to disable for all gadgets, otherwise it will not be easy to process events between shortcuts and selected gadgets.

Posted: Sat Aug 27, 2005 5:33 am
by sk8terboi
Ok thanks! Sorry I didn't understand at first! I'll try that :!: :!: :D