From: Robert M. <rob...@us...> - 2007-04-24 19:23:40
|
On 24/04/07, Glenn Linderman <pe...@ne...> wrote: > $mw->AddCheckbox( > -name => "cb", > -text => 'click me', > -pos => [10, 20], > -tabstop => 1, > -onClick => sub { return 0; }, > ); > > Why does the above program allow the checkbox to be checked and > unchecked? Why doesn't the -onClick handler, which returns 0, prevent > the box from being checked? Because the _Click() events are generated by the Button control AFTER it sees a mouse down and up combination. At this point the control has seen a "click" and sends a BTN_CLICK (IIRC) notification to it's parent - it's already done all the other processing. You could achieve what you are trying here by catching the _MouseDown event, and preventing that being delivered to the Button control. You could also achieve what (I think) you are looking for by creating the control with the BS_CHECKBOX style, rather than the default BS_AUTOCHECKBOX. Then the control does not re-drw itself, and you have to tell it how it should look. Regards, Rob. |