home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / BC_502 / SCRPTEXM.PAK / KEYASSGN.SPP < prev    next >
Encoding:
Text File  |  1997-05-06  |  1.7 KB  |  62 lines

  1. //--------------------------------------------------------------------------
  2. // Object Scripting
  3. // Copyright (c) 1996, 1997 by Borland International, All Rights Reserved
  4. //
  5. // KEYASSGN.SPP: Key Assignments. Shows what commands are assigned to a
  6. //   given key sequence.
  7. //
  8. // USE: Run script, and enter the key sequence.
  9. //--------------------------------------------------------------------------
  10. print typeid(module());
  11.  
  12. //
  13. // IDE imports.
  14. //
  15. import IDE;
  16.  
  17. keyassgn()
  18. {
  19.   // Get the keys.
  20.   //
  21.   declare keys;
  22.   keys = IDE.KeyPressDialog("Enter the key sequence to check", NULL);
  23.  
  24.   if (keys) {
  25.     // Create a top-level message for the key sequence.
  26.     //
  27.     declare parent;
  28.     parent = IDE.MessageCreate("Keyassgn", NULL, INFORMATION, 0,
  29.                                "Commands assigned to " + keys, NULL,
  30.                                NULL, NULL, NULL, NULL);
  31.  
  32.     // Check each subsystem keyboard.
  33.     //
  34.     CheckKbd("Editor", parent, keys);
  35.     CheckKbd("ClassExpert", parent, keys);
  36.     CheckKbd("Message", parent, keys);
  37.     CheckKbd("Project", parent, keys);
  38.     CheckKbd("Browser", parent, keys);
  39.     CheckKbd("Desktop", parent, keys);
  40.     CheckKbd("Default", parent, keys);
  41.  
  42.     // Show results.
  43.     //
  44.     IDE.ViewMessage("Keyassgn");
  45.   }
  46. }
  47.  
  48. //
  49. // Checks a keyboard for assigned command, and reports command if found.
  50. //
  51. CheckKbd(subSystem, parentMsg, keys)
  52. {
  53.   declare kbd = IDE.KeyboardManager.GetKeyboard(subSystem);
  54.   declare cmd = kbd.GetCommand(keys);
  55.   
  56.   if (cmd) {
  57.     IDE.MessageCreate("Keyassgn", NULL, INFORMATION, parentMsg, NULL, NULL,
  58.                       NULL, subSystem + " -> " + cmd, NULL, NULL);
  59.   }
  60. }
  61.  
  62.