1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 """Interface for adding and removing C{FocusEvent} listeners."""
17
18 from muntjac.terminal.gwt.client.event_id import EventId
19 from muntjac.event.component_event_listener import IComponentEventListener
20 from muntjac.ui.component import Event as ComponentEvent
21
22
24 """The interface for adding and removing C{FocusEvent} listeners.
25 By implementing this interface a class explicitly announces that it will
26 generate a C{FocusEvent} when it receives keyboard focus.
27
28 @see: L{IFocusListener}
29 @see: L{FocusEvent}
30 """
31
33 """Adds a C{IFocusListener} to the Component which gets fired
34 when a C{Field} receives keyboard focus.
35
36 @see: L{IFocusListener}
37 """
38 raise NotImplementedError
39
40
41 - def addCallback(self, callback, eventType=None, *args):
42 raise NotImplementedError
43
44
46 """Removes a C{IFocusListener} from the Component.
47
48 @see: L{IFocusListener}
49 """
50 raise NotImplementedError
51
52
54 raise NotImplementedError
55
56
58 """The interface for adding and removing C{BlurEvent} listeners.
59 By implementing this interface a class explicitly announces that it will
60 generate a C{BlurEvent} when it loses keyboard focus.
61
62 @see: L{IBlurListener}
63 @see: L{BlurEvent}
64 """
65
67 """Adds a C{IBlurListener} to the Component which gets fired
68 when a C{Field} loses keyboard focus.
69
70 @see: L{IBlurListener}
71 """
72 raise NotImplementedError
73
74
75 - def addCallback(self, callback, eventType=None, *args):
76 raise NotImplementedError
77
78
80 """Removes a C{IBlurListener} from the Component.
81
82 @see: L{IBlurListener}
83 """
84 raise NotImplementedError
85
86
88 raise NotImplementedError
89
90
92 """C{FocusEvent} class for holding additional event information.
93 Fired when a C{Field} receives keyboard focus.
94 """
95
96 EVENT_ID = EventId.FOCUS
97
100
101
103 """C{IFocusListener} interface for listening for C{FocusEvent} fired by
104 a C{Field}.
105
106 @see: FocusEvent
107 """
108
110 """Component has been focused
111
112 @param event:
113 Component focus event.
114 """
115 raise NotImplementedError
116
117 focusMethod = focus
118
119
121 """C{BlurEvent} class for holding additional event information.
122 Fired when a C{Field} loses keyboard focus.
123 """
124
125
126 EVENT_ID = EventId.BLUR
127
130
131
133 """C{IBlurListener} interface for listening for C{BlurEvent} fired by
134 a C{Field}.
135
136 @see: BlurEvent
137 """
138
139 - def blur(self, event):
140 """Component has been blurred
141
142 @param event:
143 Component blur event.
144 """
145 raise NotImplementedError
146
147 blurMethod = blur
148
149
150 -class TextChangeEvent(ComponentEvent):
151 """TextChangeEvents are fired when the user is editing the text content of
152 a field. Most commonly text change events are triggered by typing text with
153 keyboard, but e.g. pasting content from clip board to a text field also
154 triggers an event.
155
156 TextChangeEvents differ from L{ValueChangeEvent}s so that they are
157 triggered repeatedly while the end user is filling the field.
158 ValueChangeEvents are not fired until the user for example hits enter or
159 focuses another field. Also note the difference that TextChangeEvents are
160 only fired if the change is triggered from the user, while
161 ValueChangeEvents are also fired if the field value is set by the
162 application code.
163
164 The L{ITextChangeNotifier}s implementation may decide when exactly
165 TextChangeEvents are fired. TextChangeEvents are not necessary fire for
166 example on each key press, but buffered with a small delay. The
167 L{TextField} component supports different modes for triggering
168 TextChangeEvents.
169
170 @see: L{ITextChangeListener}
171 @see: L{ITextChangeNotifier}
172 @see: TextField.setTextChangeEventMode
173 """
174
175 - def __init__(self, source):
176 super(TextChangeEvent, self).__init__(source)
177
178
180 """@return: the text content of the field after the
181 L{TextChangeEvent}
182 """
183 pass
184
185
187 """@return: the cursor position during after the
188 L{TextChangeEvent}"""
189 pass
190
191
192 -class ITextChangeListener(IComponentEventListener):
193 """A listener for L{TextChangeEvent}s.
194 """
195
196 EVENT_ID = 'ie'
197
198 - def textChange(self, event):
199 """This method is called repeatedly while the text is edited by a
200 user.
201
202 @param event:
203 the event providing details of the text change
204 """
205 raise NotImplementedError
206
207
208 EVENT_METHOD = ITextChangeListener.textChange
209
210
212 """An interface implemented by a L{Field} supporting
213 L{TextChangeEvent}s. An example a L{TextField} supports
214 L{ITextChangeListener}s.
215 """
216
217 - def addListener(self, listener, iface=None):
218 raise NotImplementedError
219
220
221 - def addCallback(self, callback, eventType=None, *args):
222 raise NotImplementedError
223
224
225 - def removeListener(self, listener, iface=None):
226 raise NotImplementedError
227
228
229 - def removeCallback(self, callback, eventType=None):
230 raise NotImplementedError
231