/*
*
* PrefHotkeys.xml : PrefHotkeys
*
*/
var gSelectedHotkeyLvIndex;
function OnPrefHotkeysEvent_LstViewClicked(pPlusWnd, sControlId, nItemIdx) {
if (sControlId === 'LvHotkeys') {
var bEnable = (nItemIdx !== -1)
_win32.EnableWindow(objChildWindows['PrefHotkeys'].GetControlHandle('BtnHkEdit'), bEnable);
_win32.EnableWindow(objChildWindows['PrefHotkeys'].GetControlHandle('BtnHkDelete'), bEnable);
gSelectedHotkeyLvIndex = nItemIdx;
}
PrefHotkeys_SwapButtons(pPlusWnd, sControlId, nItemIdx);
}
function OnPrefHotkeysEvent_CtrlClicked(pPlusWnd, sControlId) {
switch (sControlId) {
case 'BtnSave':
Preferences_Save('PrefHotkeys');
case 'BtnBack':
Preferences_ShowChild('PrefDashboard');
break;
case 'BtnHkAdd':
objPrefTemp['HotkeyEditing'] = -1;
var tWnd = objChildWindows['PrefHkAddEdit'];
_win32.SendMessageW(tWnd.GetControlHandle('hkHotKeyCombination'), _win32._const._HK_SETKEY, 0, 0);
for (var i=0; i<10; ++i) {
tWnd.Combo_AddItem('cboActions', _lang.text['HotkeyActions_' + i], i);
}
tWnd.Combo_SetCurSel('cboActions', 0);
Preferences_ShowChild('PrefHkAddEdit');
break;
case 'BtnHkEdit':
var hk = pPlusWnd.LstView_GetItemText('LvHotkeys', gSelectedHotkeyLvIndex, 2);
objPrefTemp['HotkeyEditing'] = hk;
var tWnd = objChildWindows['PrefHkAddEdit'];
var _mKey = Registry_GetKeyValue(HKCU, RegistryInit() + '\\Hotkeys\\' + hk, 'Hotkey');
var _mAction = Registry_GetKeyValue(HKCU, RegistryInit() + '\\Hotkeys\\' + hk, 'Action');
_win32.SendMessageW(tWnd.GetControlHandle('hkHotKeyCombination'), _win32._const._HK_SETKEY, _mKey, 0);
for (var i=0; i<10; ++i) {
tWnd.Combo_AddItem('cboActions', _lang.text['HotkeyActions_' + i], i);
}
tWnd.Combo_SetCurSel('cboActions', _mAction);
Preferences_ShowChild('PrefHkAddEdit');
break;
case 'BtnHkDelete':
var Result = _win32.MessageBoxW(0, _lang.text['MsgBoxDeleteHotkey'], _lang.text['MsgBoxDeleteHotkey_Title'], 0x124);
if (Result === 7) break;
_win32.EnableWindow(pPlusWnd.GetControlHandle('BtnHkDelete'), false);
_win32.EnableWindow(pPlusWnd.GetControlHandle('BtnHkEdit'), false);
_hotkey.PauseHotkeyHandling(true);
var hk = pPlusWnd.LstView_GetItemText('LvHotkeys', gSelectedHotkeyLvIndex, 2);
Registry_DeleteTree(HKCU, RegistryInit() + '\\Hotkeys\\' + hk);
ClearListView(pPlusWnd.GetControlHandle('LvHotkeys'));
_hotkey.LoadConfiguredHotkeys(pPlusWnd, 'LvHotkeys');
_hotkey.LoadHotkeys();
_hotkey.PauseHotkeyHandling(false);
break;
case 'BtnHkEnable':
_hotkey.PauseHotkeyHandling(true);
Registry_SetKeyValue(HKCU, RegistryInit() +'\\Hotkeys\\'+pPlusWnd.LstView_GetItemText('LvHotkeys', gSelectedHotkeyLvIndex, 2), 'bEnabled', 1, REG_DWORD);
ClearListView(pPlusWnd.GetControlHandle('LvHotkeys'));
_hotkey.LoadConfiguredHotkeys(pPlusWnd, 'LvHotkeys');
_hotkey.LoadHotkeys();
_hotkey.PauseHotkeyHandling(false);
OnPrefHotkeysEvent_LstViewClicked(pPlusWnd, 'LvHotkeys', -1);
break;
case 'BtnHkDisable':
_hotkey.PauseHotkeyHandling(true);
Registry_SetKeyValue(HKCU, RegistryInit() +'\\Hotkeys\\'+pPlusWnd.LstView_GetItemText('LvHotkeys', gSelectedHotkeyLvIndex, 2), 'bEnabled', 0, REG_DWORD);
ClearListView(pPlusWnd.GetControlHandle('LvHotkeys'));
_hotkey.LoadConfiguredHotkeys(pPlusWnd, 'LvHotkeys');
_hotkey.LoadHotkeys();
_hotkey.PauseHotkeyHandling(false);
OnPrefHotkeysEvent_LstViewClicked(pPlusWnd, 'LvHotkeys', -1);
break;
}
}
/*
*
* PrefHotkeys.xml : PrefHkAddEdit
*
*/
function OnPrefHkAddEditEvent_CtrlClicked(pPlusWnd, sControlId) {
switch (sControlId) {
case 'BtnSave' :
if (objPrefTemp['HotkeyEditing'] === -1) {
/* Add new hotkey */
_mKey = _win32.SendMessageW(pPlusWnd.GetControlHandle('hkHotKeyCombination'), _win32._const._HK_GETKEY, 0, 0);
var NewHotkey = 1;
while (Registry_KeyExist(HKCU, RegistryInit() + '\\Hotkeys\\Hotkey ' + NewHotkey) === true) { NewHotkey ++; }
Registry_CreateKey(HKCU, RegistryInit() + '\\Hotkeys\\Hotkey ' + NewHotkey);
Registry_SetKeyValue(HKCU, RegistryInit() + '\\Hotkeys\\Hotkey ' + NewHotkey, 'Hotkey', _mKey, REG_DWORD);
Registry_SetKeyValue(HKCU, RegistryInit() + '\\Hotkeys\\Hotkey ' + NewHotkey, 'Action', pPlusWnd.Combo_GetCurSel('cboActions'), REG_DWORD);
Registry_SetKeyValue(HKCU, RegistryInit() + '\\Hotkeys\\Hotkey ' + NewHotkey, 'bEnabled', 1, REG_DWORD);
} else {
/* Edit hotkey */
var hk = objPrefTemp['HotkeyEditing'];
_mKey = _win32.SendMessageW(pPlusWnd.GetControlHandle('hkHotKeyCombination'), _win32._const._HK_GETKEY, 0, 0);
Registry_SetKeyValue(HKCU, RegistryInit() + '\\Hotkeys\\' + hk, 'Hotkey', _mKey, REG_DWORD);
Registry_SetKeyValue(HKCU, RegistryInit() + '\\Hotkeys\\' + hk, 'Action', pPlusWnd.Combo_GetCurSel('cboActions'), REG_DWORD);
}
ClearListView(objChildWindows['PrefHotkeys'].GetControlHandle('LvHotkeys'));
_hotkey.LoadConfiguredHotkeys(objChildWindows['PrefHotkeys'], 'LvHotkeys');
case 'BtnBack' :
Preferences_ShowChild('PrefHotkeys');
}
}
function PrefHotkeys_SwapButtons(o, s, i) {
if (i === -1) {
_win32.EnableWindow(o.GetControlHandle('BtnHkEnable'), false);
_win32.EnableWindow(o.GetControlHandle('BtnHkDisable'), false);
return;
}
switch (parseFloat(o.LstView_GetItemText(s, i, 3))) {
case 0:
_win32.EnableWindow(o.GetControlHandle('BtnHkDisable'), false);
_win32.EnableWindow(o.GetControlHandle('BtnHkEnable'), true);
_win32.ShowWindow(o.GetControlHandle('BtnHkDisable'), _win32._const._SW_HIDE);
_win32.ShowWindow(o.GetControlHandle('BtnHkEnable'), _win32._const._SW_SHOW);
break;
case 1:
_win32.EnableWindow(o.GetControlHandle('BtnHkDisable'), true);
_win32.EnableWindow(o.GetControlHandle('BtnHkEnable'), false);
_win32.ShowWindow(o.GetControlHandle('BtnHkDisable'), _win32._const._SW_SHOW);
_win32.ShowWindow(o.GetControlHandle('BtnHkEnable'), _win32._const._SW_HIDE);
break;
}
}