comparison dynamin/gui/control.d @ 47:41b76c218851

Change keyUp, keyDown, and keyTyped to bubble to a control's parent if not stopped.
author Jordan Miner <jminer7@gmail.com>
date Tue, 04 Aug 2009 20:28:18 -0500
parents d55b5b998412
children 62742ce025ec
comparison
equal deleted inserted replaced
46:127b9d99c01c 47:41b76c218851
102 mouseTurned.callHandlers(e); 102 mouseTurned.callHandlers(e);
103 mouseTurned.callMainHandler(e); 103 mouseTurned.callMainHandler(e);
104 if(!e.stopped && _parent) 104 if(!e.stopped && _parent)
105 _parent.mouseTurned(e); 105 _parent.mouseTurned(e);
106 } 106 }
107 protected void dispatchKeyDown(KeyEventArgs e) {
108 keyDown.callHandlers(e);
109 keyDown.callMainHandler(e);
110 if(!e.stopped && _parent)
111 _parent.keyDown(e);
112 }
113 protected void dispatchKeyUp(KeyEventArgs e) {
114 keyUp.callHandlers(e);
115 keyUp.callMainHandler(e);
116 if(!e.stopped && _parent)
117 _parent.keyUp(e);
118 }
119 protected void dispatchKeyTyped(KeyTypedEventArgs e) {
120 keyTyped.callHandlers(e);
121 keyTyped.callMainHandler(e);
122 if(!e.stopped && _parent)
123 _parent.keyTyped(e);
124 }
107 protected void dispatchPainting(PaintingEventArgs e) { 125 protected void dispatchPainting(PaintingEventArgs e) {
108 e.graphics.save(); 126 e.graphics.save();
109 painting.callMainHandler(e); 127 painting.callMainHandler(e);
110 e.graphics.restore(); 128 e.graphics.restore();
111 e.graphics.save(); 129 e.graphics.save();
153 protected void whenMouseDragged(MouseEventArgs e) { } 171 protected void whenMouseDragged(MouseEventArgs e) { }
154 /// This event occurs after the mouse has been moved. 172 /// This event occurs after the mouse has been moved.
155 Event!(whenMouseDragged) mouseDragged; 173 Event!(whenMouseDragged) mouseDragged;
156 174
157 /// Override this method in a subclass to handle the mouseTurned event. 175 /// Override this method in a subclass to handle the mouseTurned event.
176 /// If this event is not stopped, it will be sent to the control's parent.
158 protected void whenMouseTurned(MouseTurnedEventArgs e) { } 177 protected void whenMouseTurned(MouseTurnedEventArgs e) { }
159 /// This event occurs after the mouse wheel has been turned. 178 /// This event occurs after the mouse wheel has been turned.
160 Event!(whenMouseTurned) mouseTurned; 179 Event!(whenMouseTurned) mouseTurned;
161 180
162 /// Override this method in a subclass to handle the keyDown event. 181 /// Override this method in a subclass to handle the keyDown event.
182 /// If this event is not stopped, it will be sent to the control's parent.
163 protected void whenKeyDown(KeyEventArgs e) { } 183 protected void whenKeyDown(KeyEventArgs e) { }
164 /// This event occurs after a key is pressed. 184 /// This event occurs after a key is pressed.
165 Event!(whenKeyDown) keyDown; 185 Event!(whenKeyDown) keyDown;
166 186
167 /// Override this method in a subclass to handle the keyTyped event. 187 /// Override this method in a subclass to handle the keyTyped event.
188 /// If this event is not stopped, it will be sent to the control's parent.
168 protected void whenKeyTyped(KeyTypedEventArgs e) { } 189 protected void whenKeyTyped(KeyTypedEventArgs e) { }
169 /// This event occurs after a character key is pressed. 190 /// This event occurs after a character key is pressed.
170 Event!(whenKeyTyped) keyTyped; 191 Event!(whenKeyTyped) keyTyped;
171 192
172 /// Override this method in a subclass to handle the keyUp event. 193 /// Override this method in a subclass to handle the keyUp event.
194 /// If this event is not stopped, it will be sent to the control's parent.
173 protected void whenKeyUp(KeyEventArgs e) { } 195 protected void whenKeyUp(KeyEventArgs e) { }
174 /// This event occurs after a key is released. 196 /// This event occurs after a key is released.
175 Event!(whenKeyUp) keyUp; 197 Event!(whenKeyUp) keyUp;
176 198
177 /// Override this method in a subclass to handle the painting event. 199 /// Override this method in a subclass to handle the painting event.
197 mouseDragged.mainHandler = &whenMouseDragged; 219 mouseDragged.mainHandler = &whenMouseDragged;
198 mouseDragged.dispatcher = &dispatchMouseDragged; 220 mouseDragged.dispatcher = &dispatchMouseDragged;
199 mouseTurned.mainHandler = &whenMouseTurned; 221 mouseTurned.mainHandler = &whenMouseTurned;
200 mouseTurned.dispatcher = &dispatchMouseTurned; 222 mouseTurned.dispatcher = &dispatchMouseTurned;
201 keyDown.mainHandler = &whenKeyDown; 223 keyDown.mainHandler = &whenKeyDown;
224 keyDown.dispatcher = &dispatchKeyDown;
202 keyTyped.mainHandler = &whenKeyTyped; 225 keyTyped.mainHandler = &whenKeyTyped;
226 keyTyped.dispatcher = &dispatchKeyTyped;
203 keyUp.mainHandler = &whenKeyUp; 227 keyUp.mainHandler = &whenKeyUp;
228 keyUp.dispatcher = &dispatchKeyUp;
204 painting.mainHandler = &whenPainting; 229 painting.mainHandler = &whenPainting;
205 painting.dispatcher = &dispatchPainting; 230 painting.dispatcher = &dispatchPainting;
206 231
207 _location = Point(0, 0); 232 _location = Point(0, 0);
208 _size = Size(100, 100); 233 _size = Size(100, 100);