# HG changeset patch # User Diggory Hardy # Date 1217267358 -3600 # Node ID 65780e0e48e6f4b3acf722364b078db5c22778ff # Parent 25cb7420dc91d1f7f8164fb30bed008c32439b9b Re-enabled click event passing in the gui to make ButtonWidget work. Bugfix (pass void* not class reference). Change to allow compilation with dmd 1.027 (don't use DefaultData's Arg!() template). diff -r 25cb7420dc91 -r 65780e0e48e6 mde/font/font.d --- a/mde/font/font.d Mon Jul 28 18:17:48 2008 +0100 +++ b/mde/font/font.d Mon Jul 28 18:49:18 2008 +0100 @@ -106,7 +106,7 @@ reader.read; // get fallback name - char[]* p = "fallback" in reader.dataset.header.Arg!(char[]); + char[]* p = "fallback" in reader.dataset.header._charA; if (p is null) throw new fontException ("No fallback font style specified"); fallbackName = *p; diff -r 25cb7420dc91 -r 65780e0e48e6 mde/gui/WidgetData.d --- a/mde/gui/WidgetData.d Mon Jul 28 18:17:48 2008 +0100 +++ b/mde/gui/WidgetData.d Mon Jul 28 18:49:18 2008 +0100 @@ -92,7 +92,7 @@ // Read from the HEADER: // Get the renderer - char[]* p = "Renderer" in reader.dataset.header.Arg!(char[]); + char[]* p = "Renderer" in reader.dataset.header._charA; if (p is null || *p is null) { logger.warn ("No renderer specified: using \"Simple\""); rendName = "Simple"; @@ -101,7 +101,7 @@ rendName = *p; // Get which section to use - p = "Design" in reader.dataset.header.Arg!(char[]); + p = "Design" in reader.dataset.header._charA; if (p is null || *p is null) { logger.warn ("No gui design specified: trying \"Default\""); defaultDesign = "Default"; diff -r 25cb7420dc91 -r 65780e0e48e6 mde/gui/WidgetManager.d --- a/mde/gui/WidgetManager.d Mon Jul 28 18:17:48 2008 +0100 +++ b/mde/gui/WidgetManager.d Mon Jul 28 18:49:18 2008 +0100 @@ -90,7 +90,11 @@ // See IWidgetManager.addClickCallback's documentation: if (dg (cast(wdabs)cx, cast(wdabs)cy, b, state)) return; - /+ + // NOTE: do we need to test if the click was on the gui (and thus child)? + IChildWidget widg = child.getWidget (cast(wdabs)cx,cast(wdabs)cy); + if (widg !is null) + widg.clickEvent (cast(wdabs)cx,cast(wdabs)cy,b,state); + /+ FIXME: remove foreach (i,w; windows) { IWidget widg = w.getWidget (cast(wdabs)cx,cast(wdabs)cy); if (widg !is null) { @@ -150,9 +154,9 @@ void addMotionCallback (void delegate(wdabs, wdabs) dg) { motionCallbacks[dg.ptr] = dg; } - void removeCallbacks (IChildWidget frame) { - clickCallbacks.remove(cast(void*) frame); - motionCallbacks.remove(cast(void*) frame); + void removeCallbacks (void* frame) { + clickCallbacks.remove(frame); + motionCallbacks.remove(frame); } //END IWidgetManager methods diff -r 25cb7420dc91 -r 65780e0e48e6 mde/gui/widget/Ifaces.d --- a/mde/gui/widget/Ifaces.d Mon Jul 28 18:17:48 2008 +0100 +++ b/mde/gui/widget/Ifaces.d Mon Jul 28 18:49:18 2008 +0100 @@ -108,7 +108,10 @@ // User input: - /** Add a mouse click callback: delegate will be called for all mouse click events recieved. + /** Add a mouse click callback. + * + * This is a delegate this will be called for all mouse click events recieved by the gui, not + * simply all click events on the widget (as clickEvent recieves). * * The delegate should return true if it accepts the event and no further processing is * required (i.e. the event should not be handled by anything else), false otherwise. @@ -117,13 +120,15 @@ * may be removed (so event handling cannot be cut short). */ void addClickCallback (bool delegate (wdabs cx, wdabs cy, ubyte b, bool state) dg); - /** Add a mouse motion callback: delegate will be called for all motion events recieved. */ + /** Add a mouse motion callback: delegate will be called for all motion events recieved by the + * gui. */ void addMotionCallback (void delegate (wdabs cx, wdabs cy) dg); // FIXME: keyboard callback (letter only, for text input? Also used for setting keybindings though...) /** Remove all event callbacks on this widget (according to the delegate's .ptr). */ - void removeCallbacks (IChildWidget frame); + // Note: don't try to pass a reference and cast to void* in the function; it's a different address. + void removeCallbacks (void* frame); } @@ -236,7 +241,7 @@ * (x,y). * * Note: use global coordinates (x,y) not coordinates relative to the widget. */ - IWidget getWidget (wdim x, wdim y); + IChildWidget getWidget (wdim x, wdim y); /** Receive a mouse click event. * diff -r 25cb7420dc91 -r 65780e0e48e6 mde/gui/widget/Widget.d --- a/mde/gui/widget/Widget.d Mon Jul 28 18:17:48 2008 +0100 +++ b/mde/gui/widget/Widget.d Mon Jul 28 18:49:18 2008 +0100 @@ -77,7 +77,7 @@ //BEGIN Events /* This method is only called when the location is over this widget; hence for all widgets * without children this method is valid. */ - IWidget getWidget (wdim,wdim) { + IChildWidget getWidget (wdim,wdim) { return this; } diff -r 25cb7420dc91 -r 65780e0e48e6 mde/gui/widget/miscWidgets.d --- a/mde/gui/widget/miscWidgets.d Mon Jul 28 18:17:48 2008 +0100 +++ b/mde/gui/widget/miscWidgets.d Mon Jul 28 18:49:18 2008 +0100 @@ -85,7 +85,7 @@ pushed = false; mgr.requestRedraw; - mgr.removeCallbacks (this); + mgr.removeCallbacks (cast(void*) this); return true; }