1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef mozilla_textinputdispatcherlistener_h_
6 #define mozilla_textinputdispatcherlistener_h_
8 #include "nsWeakReference.h"
13 class TextEventDispatcher
;
14 struct IMENotification
;
15 struct IMENotificationRequests
;
17 #define NS_TEXT_INPUT_PROXY_LISTENER_IID \
21 {0x8a, 0x24, 0xce, 0x4d, 0x5b, 0x38, 0x15, 0xf0}};
23 class TextEventDispatcherListener
: public nsSupportsWeakReference
{
25 NS_DECLARE_STATIC_IID_ACCESSOR(NS_TEXT_INPUT_PROXY_LISTENER_IID
)
28 * NotifyIME() is called by TextEventDispatcher::NotifyIME(). This is a
29 * notification or request to IME. See document of nsIWidget::NotifyIME()
32 NS_IMETHOD
NotifyIME(TextEventDispatcher
* aTextEventDispatcher
,
33 const IMENotification
& aNotification
) = 0;
36 * Returns preference for which IME notification are received by NotifyIME().
38 NS_IMETHOD_(IMENotificationRequests
) GetIMENotificationRequests() = 0;
41 * OnRemovedFrom() is called when the TextEventDispatcher stops working and
42 * is releasing the listener.
45 OnRemovedFrom(TextEventDispatcher
* aTextEventDispatcher
) = 0;
48 * WillDispatchKeyboardEvent() may be called immediately before
49 * TextEventDispatcher dispatching a keyboard event. This is called only
50 * during calling TextEventDispatcher::DispatchKeyboardEvent() or
51 * TextEventDispatcher::MaybeDispatchKeypressEvents(). But this may not
52 * be called if TextEventDispatcher thinks that the keyboard event doesn't
53 * need alternative char codes.
55 * This method can overwrite any members of aKeyboardEvent which is already
56 * initialized by TextEventDispatcher. If it's necessary, this method should
57 * overwrite the charCode when Control key is pressed. TextEventDispatcher
58 * computes charCode from mKeyValue. However, when Control key is pressed,
59 * charCode should be an ASCII char. In such case, this method needs to
60 * overwrite it properly.
62 * @param aTextEventDispatcher Pointer to the caller.
63 * @param aKeyboardEvent The event trying to dispatch.
64 * This is already initialized, but if it's
65 * necessary, this method should overwrite the
66 * members and set alternative char codes.
67 * @param aIndexOfKeypress When aKeyboardEvent is eKeyPress event,
68 * it may be a sequence of keypress events
69 * if the key causes multiple characters.
70 * In such case, this indicates the index from
71 * first keypress event.
72 * If aKeyboardEvent is the first eKeyPress or
73 * other events, this value is 0.
74 * @param aData The pointer which was specified at calling
75 * the method of TextEventDispatcher.
76 * For example, if you do:
77 * |TextEventDispatcher->DispatchKeyboardEvent(
78 * eKeyDown, event, status, this);|
79 * Then, aData of this method becomes |this|.
80 * Finally, you can use it like:
81 * |static_cast<NativeEventHandler*>(aData)|
84 WillDispatchKeyboardEvent(TextEventDispatcher
* aTextEventDispatcher
,
85 WidgetKeyboardEvent
& aKeyboardEvent
,
86 uint32_t aIndexOfKeypress
, void* aData
) = 0;
89 NS_DEFINE_STATIC_IID_ACCESSOR(TextEventDispatcherListener
,
90 NS_TEXT_INPUT_PROXY_LISTENER_IID
)
93 } // namespace mozilla
95 #endif // #ifndef mozilla_textinputdispatcherlistener_h_