|
Re: ANNOUNCE ex11 release two: msg#00249lang.erlang.general
On Thu, 22 Jan 2004, Vlad Dumitrescu wrote: > Hi again, > > I suppose that the use of callbacks will not remain as it is now: the fun is > evaluated in the main loop of the widget. I think it should either be spawned, > or the mechanism be replaced with message sending to an owner-process (like in > gs, IIRC) On the contrary I think this is *exactly* how it should be done. I have experimented with many different styles of callback handling and IMHO this is the best. If you want to do it with messages you can write your top-level thing like this: B = swButton:make(Win ......) S = self(), B ! {onClick, fun(X) -> S ! {wrapper, X} end}, ... loop(...). loop(...) -> receive {wrapper, X} -> Do something ... end Note the Fun is evaluated in the main loop of the widget NOT in the application and NOT in the driver. I have totally re-written the widget libraries at least five times, and feel this structure is best. If you don't do it like this life gets difficult. Suppose you make a top level window with 20 widgets in it. You don't want to forward messages from all the widgets to the top-level controller, only a few of them - so you set up callbacks within the individual widgets. If you did want all the messages you just make the funs send messages to the required process as in the example above. Cheers /Joe |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: ANNOUNCE ex11 release two: 00249, Vlad Dumitrescu |
|---|---|
| Next by Date: | OS scheduling vs. VM scheduling: 00249, Joachim Durchholz |
| Previous by Thread: | Re: ANNOUNCE ex11 release twoi: 00249, Vlad Dumitrescu |
| Next by Thread: | Re: ANNOUNCE ex11 release two: 00249, Vlad Dumitrescu |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |