tags:

views:

27

answers:

0

Hello,

I want to use double key shortcuts like in MS Visual Studio but I have problems defining them. I use CodeJock and therefore the CXTPShortcutManager.

If I manually assign a shortcut e.g. "Ctrl+K, Ctrl+C" directly in the program for a menu action it works properly. However, I was unable to define such a double key shortcut within the code.

I tried the following in MainFrame::OnCreate:

 /* ... */

 //
 // Shortcuts
 //
 pCommandBars->GetShortcutManager()->SetAccelerators(IDR_MAINFRAME);

 // allow double key shortcuts(ex: Ctrl+K, Ctrl+V)
 pCommandBars->GetShortcutManager()->m_bAllowDoubleKeyShortcuts = TRUE;

 CXTPShortcutManagerAccelTable* pShortCutTable = 
  pCommandBars->GetShortcutManager()->GetDefaultAccelerator();
 if( pShortCutTable )
 {
  XTP_SHORTCUTMANAGER_ACCEL accel = {0};
  // NOTE: the key codes are not documented within CodeJock (Arrrgggh!) !
  // use FCONTROL, FALT, FSHIFT

  // comment (Ctrl+K, Ctrl+C)
  accel.cmd = IDM_CODE_COMMENT;
  accel.key[0].fVirt = FCONTROL;
  accel.key[0].key = 'K';
  accel.key[1].fVirt = FCONTROL;
  accel.key[1].key = 'C';
  pShortCutTable->Add(accel);

  // uncomment (Ctrl+K, Ctrl+U)
  accel.cmd = IDM_CODE_COMMENT_BACK;
  accel.key[0].fVirt = FCONTROL;
  accel.key[0].key = 'K';
  accel.key[1].fVirt = FCONTROL;
  accel.key[1].key = 'U';
  pShortCutTable->Add(accel);
 }

 //
 // Load the previous state for actions view, docking panes and tool bars.
 //
 SaveLayout_(text_layout_default); // save default layout for later
 LoadLayout_(text_layout_user);  // restore last user layout (style is also restored)

 /* ... */

With this implementation nothing happens on keypress.

Any hints?