On 3/25/07, Edgar Gonçalves edgar.goncalves@gmail.com wrote:
Hi! I've just started playing with graphic-forms, and I wanted to build some macros to generate message-boxes (which I did based on your demo about-dialog), and some input-prompts, like Yes/No questions, or a simple OK/Cancel. But I'm not figuring how I can set a return value for such functions (they seem to return the value 4 once (gfw:show dlg t) is called). Right now I managed a dirty hack by placing a global variable and making the dialog change it. but this is not as functional as I would want... Any suggestions?
Hi Edgar. Your macros could be written to establish a lexical binding and then use a closure as a callback for each widget in the dialolg. Or you could define a new dispatcher class and specify that for each widget, with one or more slots carrying important return info. You might consider constructing your macros such that the user of the macro provides one or more symbols to identify bindings whose values are to carry whatever result info your dialogs will provide, which can then be accessed within the body of the macro. The WITH-* macros for the color, file, and font dialogs work this way.
The exact return value of GFW:SHOW is whatever the underlying window system returns -- I might change the function to return (values) just to emphasize that it's not a value that the application can use. But you could obviously implement a wrapper around GFW:SHOW if you wanted a function-based API.