Mercurial > projects > mde
comparison mde/gui/widget/Widget.d @ 99:5de5810e3516
Implemented an editable TextContent widget; it's now possible to edit text options using the GUI.
The widget supports moving the text entry-point using arrows and home/end, but there's no visual indicator or edit-point setting using the mouse.
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Fri, 14 Nov 2008 12:44:32 +0000 |
parents | dbf332403c6e |
children | 42e241e7be3e |
comparison
equal
deleted
inserted
replaced
98:49e7cfed4b34 | 99:5de5810e3516 |
---|---|
121 debug assert (cx >= x && cx < x + w && cy >= y && cy < y + h, "getWidget: not on widget (code error)"); | 121 debug assert (cx >= x && cx < x + w && cy >= y && cy < y + h, "getWidget: not on widget (code error)"); |
122 return this; | 122 return this; |
123 } | 123 } |
124 | 124 |
125 /* Dummy event method (suitable for all widgets which don't respond to events). */ | 125 /* Dummy event method (suitable for all widgets which don't respond to events). */ |
126 void clickEvent (wdabs cx, wdabs cy, ubyte b, bool state) {} | 126 int clickEvent (wdabs cx, wdabs cy, ubyte b, bool state) { |
127 return 0; | |
128 } | |
129 | |
130 /* Dummy functions: suitable for widgets with no text input. */ | |
131 void keyEvent (ushort, char[]) {} | |
132 void keyFocusLost () {} | |
127 //END Events | 133 //END Events |
128 | 134 |
129 /* Basic draw method: draw the background (all widgets should do this). */ | 135 /* Basic draw method: draw the background (all widgets should do this). */ |
130 void draw () { | 136 void draw () { |
131 mgr.renderer.drawWidgetBack (x,y, w,h); | 137 mgr.renderer.drawWidgetBack (x,y, w,h); |
219 void draw () { | 225 void draw () { |
220 mgr.renderer.drawButton (x,y, w,h, pushed); | 226 mgr.renderer.drawButton (x,y, w,h, pushed); |
221 } | 227 } |
222 | 228 |
223 /// Handles the down-click | 229 /// Handles the down-click |
224 void clickEvent (wdabs, wdabs, ubyte b, bool state) { | 230 int clickEvent (wdabs, wdabs, ubyte b, bool state) { |
225 if (b == 1 && state == true) { | 231 if (b == 1 && state == true) { |
226 pushed = true; | 232 pushed = true; |
227 mgr.requestRedraw; | 233 mgr.requestRedraw; |
228 mgr.addClickCallback (&clickWhilePushed); | 234 mgr.addClickCallback (&clickWhilePushed); |
229 mgr.addMotionCallback (&motionWhilePushed); | 235 mgr.addMotionCallback (&motionWhilePushed); |
230 } | 236 } |
237 return 0; | |
231 } | 238 } |
232 | 239 |
233 /// Called when a mouse click event occurs while held; handles up-click | 240 /// Called when a mouse click event occurs while held; handles up-click |
234 bool clickWhilePushed (wdabs cx, wdabs cy, ubyte b, bool state) { | 241 bool clickWhilePushed (wdabs cx, wdabs cy, ubyte b, bool state) { |
235 if (b == 1 && state == false) { | 242 if (b == 1 && state == false) { |