Code Viewer

./WindowHandlers/PrefHotkeys_handler.js File Size: 11.88 KB

  1. /*
  2. *
  3. *      PrefHotkeys.xml : PrefHotkeys
  4. *     
  5. */
  6.  
  7. var gSelectedHotkeyLvIndex;
  8.  
  9. function OnPrefHotkeysEvent_LstViewClicked(pPlusWnd, sControlId, nItemIdx) {
  10.         if (sControlId === 'LvHotkeys') {
  11.                 var bEnable = (nItemIdx !== -1)
  12.                 _win32.EnableWindow(objChildWindows['PrefHotkeys'].GetControlHandle('BtnHkEdit'), bEnable);
  13.                 _win32.EnableWindow(objChildWindows['PrefHotkeys'].GetControlHandle('BtnHkDelete'), bEnable);
  14.                 gSelectedHotkeyLvIndex = nItemIdx;     
  15.         }
  16.  
  17.         PrefHotkeys_SwapButtons(pPlusWnd, sControlId, nItemIdx);
  18. }
  19.  
  20. function OnPrefHotkeysEvent_CtrlClicked(pPlusWnd, sControlId) {
  21.         switch (sControlId) {
  22.                 case 'BtnSave':
  23.                         Preferences_Save('PrefHotkeys');
  24.                 case 'BtnBack':
  25.                         Preferences_ShowChild('PrefDashboard');
  26.                         break;
  27.                 case 'BtnHkAdd':
  28.                         objPrefTemp['HotkeyEditing'] = -1;
  29.                         var tWnd = objChildWindows['PrefHkAddEdit'];
  30.                         _win32.SendMessageW(tWnd.GetControlHandle('hkHotKeyCombination'), _win32._const._HK_SETKEY, 0, 0);
  31.                         for (var i=0; i<10; ++i) {
  32.                                 tWnd.Combo_AddItem('cboActions', _lang.text['HotkeyActions_' + i], i);
  33.                         }
  34.                         tWnd.Combo_SetCurSel('cboActions', 0);
  35.                         Preferences_ShowChild('PrefHkAddEdit');
  36.                         break;
  37.                 case 'BtnHkEdit':
  38.                         var hk = pPlusWnd.LstView_GetItemText('LvHotkeys', gSelectedHotkeyLvIndex, 2);
  39.                         objPrefTemp['HotkeyEditing'] = hk;
  40.                         var tWnd = objChildWindows['PrefHkAddEdit'];
  41.                         var _mKey = Registry_GetKeyValue(HKCU, RegistryInit() + '\\Hotkeys\\' + hk, 'Hotkey');
  42.                         var _mAction = Registry_GetKeyValue(HKCU, RegistryInit() + '\\Hotkeys\\' + hk, 'Action');
  43.                         _win32.SendMessageW(tWnd.GetControlHandle('hkHotKeyCombination'), _win32._const._HK_SETKEY, _mKey, 0);
  44.                         for (var i=0; i<10; ++i) {
  45.                                 tWnd.Combo_AddItem('cboActions', _lang.text['HotkeyActions_' + i], i);
  46.                         }
  47.                         tWnd.Combo_SetCurSel('cboActions', _mAction);
  48.                         Preferences_ShowChild('PrefHkAddEdit');
  49.                         break;
  50.                 case 'BtnHkDelete':
  51.                         var Result = _win32.MessageBoxW(0, _lang.text['MsgBoxDeleteHotkey'], _lang.text['MsgBoxDeleteHotkey_Title'], 0x124);
  52.                         if (Result === 7) break;
  53.                         _win32.EnableWindow(pPlusWnd.GetControlHandle('BtnHkDelete'), false);
  54.                         _win32.EnableWindow(pPlusWnd.GetControlHandle('BtnHkEdit'), false);
  55.                         _hotkey.PauseHotkeyHandling(true);
  56.                         var hk = pPlusWnd.LstView_GetItemText('LvHotkeys', gSelectedHotkeyLvIndex, 2);
  57.                         Registry_DeleteTree(HKCU, RegistryInit() + '\\Hotkeys\\' + hk);
  58.                         ClearListView(pPlusWnd.GetControlHandle('LvHotkeys'));
  59.                         _hotkey.LoadConfiguredHotkeys(pPlusWnd, 'LvHotkeys');
  60.                         _hotkey.LoadHotkeys();
  61.                         _hotkey.PauseHotkeyHandling(false);
  62.                         break;
  63.                 case 'BtnHkEnable':
  64.                         _hotkey.PauseHotkeyHandling(true);
  65.                         Registry_SetKeyValue(HKCU, RegistryInit() +'\\Hotkeys\\'+pPlusWnd.LstView_GetItemText('LvHotkeys', gSelectedHotkeyLvIndex, 2), 'bEnabled', 1, REG_DWORD);
  66.                         ClearListView(pPlusWnd.GetControlHandle('LvHotkeys'));
  67.                         _hotkey.LoadConfiguredHotkeys(pPlusWnd, 'LvHotkeys');
  68.                         _hotkey.LoadHotkeys();
  69.                         _hotkey.PauseHotkeyHandling(false);
  70.                         OnPrefHotkeysEvent_LstViewClicked(pPlusWnd, 'LvHotkeys', -1);
  71.                         break;
  72.                 case 'BtnHkDisable':
  73.                         _hotkey.PauseHotkeyHandling(true);
  74.                         Registry_SetKeyValue(HKCU, RegistryInit() +'\\Hotkeys\\'+pPlusWnd.LstView_GetItemText('LvHotkeys', gSelectedHotkeyLvIndex, 2), 'bEnabled', 0, REG_DWORD);
  75.                         ClearListView(pPlusWnd.GetControlHandle('LvHotkeys'));
  76.                         _hotkey.LoadConfiguredHotkeys(pPlusWnd, 'LvHotkeys');
  77.                         _hotkey.LoadHotkeys();
  78.                         _hotkey.PauseHotkeyHandling(false);
  79.                         OnPrefHotkeysEvent_LstViewClicked(pPlusWnd, 'LvHotkeys', -1);
  80.                         break;
  81.         }
  82. }
  83.  
  84. /*
  85. *
  86. *      PrefHotkeys.xml : PrefHkAddEdit
  87. *     
  88. */
  89. function OnPrefHkAddEditEvent_CtrlClicked(pPlusWnd, sControlId) {
  90.         switch (sControlId) {
  91.                 case 'BtnSave' :
  92.                         if (objPrefTemp['HotkeyEditing'] === -1) {
  93.                                 /* Add new hotkey */
  94.                                 _mKey = _win32.SendMessageW(pPlusWnd.GetControlHandle('hkHotKeyCombination'), _win32._const._HK_GETKEY, 0, 0);
  95.                                 var NewHotkey = 1;
  96.                                 while (Registry_KeyExist(HKCU, RegistryInit() + '\\Hotkeys\\Hotkey ' + NewHotkey) === true) { NewHotkey ++; }
  97.                                 Registry_CreateKey(HKCU, RegistryInit() + '\\Hotkeys\\Hotkey ' + NewHotkey);
  98.                                 Registry_SetKeyValue(HKCU, RegistryInit() + '\\Hotkeys\\Hotkey ' + NewHotkey, 'Hotkey', _mKey, REG_DWORD);
  99.                                 Registry_SetKeyValue(HKCU, RegistryInit() + '\\Hotkeys\\Hotkey ' + NewHotkey, 'Action', pPlusWnd.Combo_GetCurSel('cboActions'), REG_DWORD);
  100.                                 Registry_SetKeyValue(HKCU, RegistryInit() + '\\Hotkeys\\Hotkey ' + NewHotkey, 'bEnabled', 1, REG_DWORD);
  101.                         } else {
  102.                                 /* Edit hotkey */
  103.                                 var hk = objPrefTemp['HotkeyEditing'];
  104.                                 _mKey = _win32.SendMessageW(pPlusWnd.GetControlHandle('hkHotKeyCombination'), _win32._const._HK_GETKEY, 0, 0);
  105.                                 Registry_SetKeyValue(HKCU, RegistryInit() + '\\Hotkeys\\' + hk, 'Hotkey', _mKey, REG_DWORD);
  106.                                 Registry_SetKeyValue(HKCU, RegistryInit() + '\\Hotkeys\\' + hk, 'Action', pPlusWnd.Combo_GetCurSel('cboActions'), REG_DWORD);
  107.                         }
  108.                         ClearListView(objChildWindows['PrefHotkeys'].GetControlHandle('LvHotkeys'));
  109.                         _hotkey.LoadConfiguredHotkeys(objChildWindows['PrefHotkeys'], 'LvHotkeys');
  110.                 case 'BtnBack' :
  111.                         Preferences_ShowChild('PrefHotkeys');
  112.         }
  113. }
  114.  
  115. function PrefHotkeys_SwapButtons(o, s, i) {
  116.         if (i === -1) {
  117.                 _win32.EnableWindow(o.GetControlHandle('BtnHkEnable'), false);
  118.                 _win32.EnableWindow(o.GetControlHandle('BtnHkDisable'), false);
  119.                 return;
  120.         }
  121.         switch (parseFloat(o.LstView_GetItemText(s, i, 3))) {
  122.                 case 0:
  123.                         _win32.EnableWindow(o.GetControlHandle('BtnHkDisable'), false);
  124.                         _win32.EnableWindow(o.GetControlHandle('BtnHkEnable'), true);
  125.                         _win32.ShowWindow(o.GetControlHandle('BtnHkDisable'), _win32._const._SW_HIDE);
  126.                         _win32.ShowWindow(o.GetControlHandle('BtnHkEnable'), _win32._const._SW_SHOW);
  127.                         break;
  128.                 case 1:
  129.                         _win32.EnableWindow(o.GetControlHandle('BtnHkDisable'), true);
  130.                         _win32.EnableWindow(o.GetControlHandle('BtnHkEnable'), false);       
  131.                         _win32.ShowWindow(o.GetControlHandle('BtnHkDisable'), _win32._const._SW_SHOW);
  132.                         _win32.ShowWindow(o.GetControlHandle('BtnHkEnable'), _win32._const._SW_HIDE);   
  133.                         break;
  134.         }
  135. }

Version

  • 5.0.0070_20100325_publicbeta1

Developers

Project Details

  • Folders8
  • Files122
  • Total Lines11,867
  • Repository Version70

User Count

  • 162