/// <summary> /// Feeds a keystroke to the Text Services Framework, wrapper for /// ITfKeystrokeMgr::TestKeyUp/TestKeyDown/KeyUp/KeyDown. /// </summary> /// <remarks> /// Must be called on the main dispatcher thread. /// </remarks> /// <returns> /// true if the keystroke will be eaten by the Text Services Framework, /// false otherwise. /// Callers should stop further processing of the keystroke on true, /// continue otherwise. /// </returns> internal bool Keystroke(int wParam, int lParam, KeyOp op) { bool fConsume; UnsafeNativeMethods.ITfKeystrokeMgr keystrokeMgr; // We delay load cicero until someone creates an ITextStore. // Or this thread may not have a ThreadMgr. if ((_threadManager == null) || (_threadManager.Value == null)) { return(false); } keystrokeMgr = _threadManager.Value as UnsafeNativeMethods.ITfKeystrokeMgr; switch (op) { case KeyOp.TestUp: keystrokeMgr.TestKeyUp(wParam, lParam, out fConsume); break; case KeyOp.TestDown: keystrokeMgr.TestKeyDown(wParam, lParam, out fConsume); break; case KeyOp.Up: keystrokeMgr.KeyUp(wParam, lParam, out fConsume); break; case KeyOp.Down: keystrokeMgr.KeyDown(wParam, lParam, out fConsume); break; default: fConsume = false; break; } return(fConsume); }
internal bool Keystroke(int wParam, int lParam, KeyOp op) { bool fConsume; UnsafeNativeMethods.ITfKeystrokeMgr keystrokeMgr; // We delay load cicero until someone creates an ITextStore. // Or this thread may not have a ThreadMgr. if ((_threadManager == null) || (_threadManager.Value == null)) return false; keystrokeMgr = _threadManager.Value as UnsafeNativeMethods.ITfKeystrokeMgr; switch (op) { case KeyOp.TestUp: keystrokeMgr.TestKeyUp(wParam, lParam, out fConsume); break; case KeyOp.TestDown: keystrokeMgr.TestKeyDown(wParam, lParam, out fConsume); break; case KeyOp.Up: keystrokeMgr.KeyUp(wParam, lParam, out fConsume); break; case KeyOp.Down: keystrokeMgr.KeyDown(wParam, lParam, out fConsume); break; default: fConsume = false; break; } return fConsume; }