[wxPython-users] Buttons and automatic key acelerators

Robin Dunn robin at alldunn.com
Sun Jun 18 13:22:42 PDT 2006


Oswaldo Hernández wrote:
> Robin Dunn escribió:
>> Oswaldo Hernández wrote:
>>
>>> Hi all,
>>>
>>> To make automatic key acelerators in Windows XP y put on the labels  
>>> an '&' before the accelerator letter:
>>>
>>> But with buttons when press the key the focus continues on the control.
>>>
>>
>> I think it is up to each control how they respond to an accelerator. 
>> For buttons it just sends a button activated event.  This is 
>> consistent with other applications I have seen that use control 
>> accelerators as well.  If you want it to do more then you need to add 
>> code for it.
>>
> 
> I notice that in my real project when press the button accelerator key 
> *sometimes* the focus is set and other times is not set.
> 
> I look into the project and i detect that when use SetBackgroundColour 
> or SetForegroundColor with buttons: *the focus is set*.

Interesting.

> 
> I attach the modified demo.
> 
> Are SetBackgroundColour and SetForegroundColor chaging any property that 
> makes it?, Which?

On Windows setting a button's colors will put it into "owner drawn" 
mode, which means that wxWidgets is then responsible for drawing the 
button.  I guess it also has the side-effect of changing some other 
native internal state as well.

-- 
Robin Dunn
Software Craftsman
http://wxPython.org  Java give you jitters?  Relax with wxPython!





More information about the wxpython-users mailing list