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; } }
private void OnControlRegistered(object sender, RegisterEventArgs e) { var windowsLanguageProfileSink = e.EventHandler as IWindowsLanguageProfileSink; if (windowsLanguageProfileSink != null && !m_windowsLanguageProfileSinks.Contains(windowsLanguageProfileSink)) m_windowsLanguageProfileSinks.Add(windowsLanguageProfileSink); if (m_profileNotifySinkCookie != 0) return; // TSF disabled, so we have to fall back to Windows messages m_tfLanguageProfileNotifySink.RegisterWindowsMessageHandler(e.Control); }