public virtual bool PreFilterMessage(ref Message m)
{
if (m.Msg != (int)Win32.WinMsgs.WM_KEYDOWN && m.Msg != (int)Win32.WinMsgs.WM_KEYUP)
return false;
Keys key = ((Keys)(int)m.WParam & Keys.KeyCode);
// There is a known issue in older versions of Keyman (< 7.1.268) where the KMTip addin sends a 0x88 keystroke
// in order to communicate changes in state to the Keyman engine. When a button is clicked while a text control
// has focus, the input language will be switched causing the keystroke to be fired, which in turn disrupts the
// mouse-click event. In order to workaround this bug for users who have older versions of Keyman, we simply filter
// out these specific keystroke messages on buttons.
if (key == Keys.ProcessKey || key == (Keys.Back | Keys.F17) /* 0x88 */)
{
Control c = Control.FromHandle(m.HWnd);
if (c != null && c is ButtonBase)
return true;
}
return false;
}