Revision | 43ba288fdeda466a8af38c2574c8ae2552a5e022 (tree) |
---|---|
Time | 2018-04-01 16:34:34 |
Author | Kazuhiro Fujieda <fujieda@user...> |
Commiter | Kazuhiro Fujieda |
Fix a bug where shift key combinations cancel the mark
@@ -693,27 +693,37 @@ HOOK_RECURSIVE_KEY: | ||
693 | 693 | return TRUE; |
694 | 694 | } |
695 | 695 | |
696 | -void CXkeymacsDll::CancelMarkWithShift(BYTE nKey, bool bRelease) | |
696 | +void CXkeymacsDll::CancelMarkWithShift(byte nKey, bool bRelease) | |
697 | 697 | { |
698 | 698 | static bool bShift; |
699 | - if (nKey != VK_SHIFT) | |
700 | - goto exit; | |
701 | - BYTE bVk = 0; | |
702 | - do { | |
703 | - if (bVk == VK_SHIFT || VK_LSHIFT || VK_RSHIFT) | |
704 | - continue; | |
705 | - if (IsDown(bVk, FALSE)) | |
706 | - goto exit; | |
707 | - } while (++bVk); | |
708 | - if (!bRelease) { | |
709 | - bShift = true; | |
699 | + if (IsDepressedShiftKeyOnly(nKey)) { | |
700 | + if (bRelease) { | |
701 | + if (bShift) | |
702 | + CCommands::SetMark(false); | |
703 | + } else { | |
704 | + bShift = true; | |
705 | + } | |
710 | 706 | return; |
711 | 707 | } |
712 | - if (bShift) | |
713 | - CCommands::SetMark(FALSE); | |
714 | -exit: | |
715 | 708 | bShift = false; |
716 | - return; | |
709 | +} | |
710 | + | |
711 | +static bool IsShift(byte bVk) | |
712 | +{ | |
713 | + return bVk == VK_SHIFT || bVk == VK_LSHIFT || bVk == VK_RSHIFT; | |
714 | +} | |
715 | + | |
716 | +bool CXkeymacsDll::IsDepressedShiftKeyOnly(byte nKey) | |
717 | +{ | |
718 | + if (!IsShift(nKey)) | |
719 | + return false; | |
720 | + for (byte bVk = 1; bVk < 255; bVk++) { | |
721 | + if (IsShift(bVk)) | |
722 | + continue; | |
723 | + if (IsDown(bVk)) | |
724 | + return false; | |
725 | + } | |
726 | + return true; | |
717 | 727 | } |
718 | 728 | |
719 | 729 | int CXkeymacsDll::IsPassThrough(BYTE nKey) |
@@ -78,7 +78,8 @@ private: | ||
78 | 78 | static BOOL m_bRightControl; |
79 | 79 | static BOOL m_bRightAlt; |
80 | 80 | static LRESULT CALLBACK KeyboardProc(int nCode, WPARAM wParam, LPARAM lParam); |
81 | - static void CancelMarkWithShift(BYTE nKey, bool bRelease); | |
81 | + static void CancelMarkWithShift(byte nKey, bool bRelease); | |
82 | + static bool IsDepressedShiftKeyOnly(byte nKey); | |
82 | 83 | static int IsPassThrough(BYTE nKey); |
83 | 84 | static void InvokeM_x(LPCTSTR szPath); |
84 | 85 | static TCHAR m_M_xTip[128]; |