From: John L. <jla...@gm...> - 2005-06-26 17:36:51
|
On 6/26/05, The Doctor <the...@bl...> wrote: > Hello, I've decided to try to use wx.wxEVT_LEFT_DCLICK and such to make s= pecific mouse events for fast access to several things via a small number o= f controls, so that this access depends on motor memory as well as visual m= emory, this being very fast and easy to use. >=20 > I've managed to make a single button (or even a static text label) be a c= ontrol for this, so it's very versatile, but there is a major drawback: the= window (control) must be assigned to a variable, and that means the event = handlers proliferate in horrible tiers of duplication. With spin controls, = it doesn't matter how many there are, or how many parent controls they're p= laced on, they're all captured by wx.wxEVT_COMMAND_SPINCTRL_UPDATED, but ob= viously I can't assign all my custom clickable controls to 'CC' to capture = with CC:ConnectEvent(-1,wx.wxEVT_LEFT_DCLICK,DoStuff). I'm not sure I understand, all events are captured by your event handler for wx.wxEVT_COMMAND_SPINCTRL_UPDATED? In terms of easing the amount of duplicate code perhaps something like this could work. (untested) function CreateMySpinCtrl(parent, id, ...) local win =3D wx.wxSpinCtrl(parent, id, ...) win:ConnectEvent(id, wx.wxEVT_COMMAND_SPINCTRL_UPDATED, func) return win -- return it for further processing if desired, ok if not us= ed end > Is there a way to group these assigned controls so a single event handler= passes the flow to a single function which filters the controls by ID as u= sual? I've thought of making tables indexed by ID so that for loops can red= uce the sixe of the source code, but this doesn't really solve the problem. Are you saying that you cannot use the same function for two separate win: ConnectEvent calls? I don't know of any reason why this shouldn't work. Maybe you could post the simplest snippet of code that shows your problem, just add a panel and two controls to the VeryMinimal.wx.lua sample. Regards, John Labenski |