private void OnControlRegistered(object sender, RegisterEventArgs e) { if (e.Control != null) { var eventHandler = e.EventHandler as IIbusEventHandler; if (eventHandler == null) { Debug.Assert(e.Control is TextBox, "Currently only TextBox controls are compatible with the default IBus event handler."); eventHandler = new IbusDefaultEventHandler((TextBox)e.Control); } KeyboardController.EventProvider.EventHandlers[e.Control] = eventHandler; IBusCommunicator.CommitText += eventHandler.OnCommitText; IBusCommunicator.UpdatePreeditText += eventHandler.OnUpdatePreeditText; IBusCommunicator.HidePreeditText += eventHandler.OnHidePreeditText; IBusCommunicator.KeyEvent += eventHandler.OnIbusKeyPress; IBusCommunicator.DeleteSurroundingText += eventHandler.OnDeleteSurroundingText; e.Control.GotFocus += HandleGotFocus; e.Control.LostFocus += HandleLostFocus; e.Control.MouseDown += HandleMouseDown; e.Control.PreviewKeyDown += HandlePreviewKeyDown; e.Control.KeyPress += HandleKeyPress; e.Control.KeyDown += HandleKeyDown; var scrollableControl = e.Control as ScrollableControl; if (scrollableControl != null) { scrollableControl.Scroll += HandleScroll; } } }
public void SetUp() { m_TextBox = new TextBox(); m_TextBox.CreateControl(); m_TextBox.Focus(); Application.DoEvents(); m_Handler = new IbusDefaultEventHandler(m_TextBox); }
private void OnControlRegistered(object sender, RegisterEventArgs e) { if (e.Control != null) { var eventHandler = e.EventHandler as IIbusEventHandler; if (eventHandler == null) { Debug.Assert(e.Control is TextBox, "Currently only TextBox controls are compatible with the default IBus event handler."); eventHandler = new IbusDefaultEventHandler((TextBox)e.Control); } KeyboardController.EventProvider.EventHandlers[e.Control] = eventHandler; IBusCommunicator.CommitText += eventHandler.OnCommitText; IBusCommunicator.UpdatePreeditText += eventHandler.OnUpdatePreeditText; IBusCommunicator.HidePreeditText += eventHandler.OnHidePreeditText; IBusCommunicator.KeyEvent += eventHandler.OnIbusKeyPress; IBusCommunicator.DeleteSurroundingText += eventHandler.OnDeleteSurroundingText; e.Control.GotFocus += HandleGotFocus; e.Control.LostFocus += HandleLostFocus; e.Control.MouseDown += HandleMouseDown; e.Control.PreviewKeyDown += HandlePreviewKeyDown; e.Control.KeyPress += HandleKeyPress; e.Control.KeyDown += HandleKeyDown; var scrollableControl = e.Control as ScrollableControl; if (scrollableControl != null) scrollableControl.Scroll += HandleScroll; } }