On Sat, Sep 11, 2010 at 10:53:26AM +0200, Marc Dirix wrote:
Maybe I'm doing something very uncommon in interface design? I have i.e. two buttons, which have the same signal handler, and in the signal handler I want to do two different things based on which of the two buttons is pressed.
What is normally done here? Do you use different signal handlers for each button, or is there a different way to determine which button is pressed? And what if the buttons are dynamically created, maybe even with the same name?
two different signal handlers does not sound to bad. if you want a common functionto do allthe work then the signal handlers could be short wrapper functions:
signal_button_1(mixed ... args) { button_handler("button_1", @args); }
signal_button_2(mixed ... args) { button_handler("button_2", @args); }
you could even hide those with inline lambda, and autogeneration of such functions should also be possible (but not if they have the same name, unless you add more info)
greetings, martin.