Keys

Just starting out? Need help? Post your questions and find answers here.
sk8terboi
User
User
Posts: 26
Joined: Mon Jun 06, 2005 3:40 am

Keys

Post 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:
Josh
fweil
Enthusiast
Enthusiast
Posts: 725
Joined: Thu Apr 22, 2004 5:56 pm
Location: France
Contact:

Post by fweil »

You should use AddKeyboardShortcut() to catch and process a specific key behaviour.
My avatar is a small copy of the 4x1.8m image I created and exposed at 'Le salon international du meuble à Paris' january 2004 in Matt Sindall's 'Shades' designers exhibition. The original laminated print was designed using a 150 dpi printout.
sk8terboi
User
User
Posts: 26
Joined: Mon Jun 06, 2005 3:40 am

Post by sk8terboi »

I meant disable not add a shortcut. Like so delete won't work.
Josh
fweil
Enthusiast
Enthusiast
Posts: 725
Joined: Thu Apr 22, 2004 5:56 pm
Location: France
Contact:

Post 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.
My avatar is a small copy of the 4x1.8m image I created and exposed at 'Le salon international du meuble à Paris' january 2004 in Matt Sindall's 'Shades' designers exhibition. The original laminated print was designed using a 150 dpi printout.
sk8terboi
User
User
Posts: 26
Joined: Mon Jun 06, 2005 3:40 am

Post by sk8terboi »

Ok thanks! Sorry I didn't understand at first! I'll try that :!: :!: :D
Josh
Post Reply