Tk Library Source Code

View Ticket
Login
Ticket UUID: 756334
Title: ComboBox doesn't take focus during keyboard traversal
Type: Bug Version: None
Submitter: pointsman Created on: 2003-06-18 00:23:55
Subsystem: bwidget Assigned To: damonc
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2009-07-01 15:27:48
Resolution: Fixed Closed By: oehhar
    Closed on: 2009-07-01 08:27:48
Description:
A ComboBox with -editable false doesn't take the focus
during keyboard traversal even with an explicite
-takefocus 1.

It's documented to work this way, but it's IMHO the
wrong behaviour. Even with -editable false the user is
able to select a value with the arrow keys. As it is
know, with a ComboBox with -editable false, a User must
always leaf the keyboard and first click the ComboBox,
to choose a value.

Proposed behaviour: with a explicite -takefocus 1 the
ComboBox takes always the focus during keyboard
traversal, even if -editable false.
User Comments: oehhar added on 2009-07-01 15:27:48:
Confirmed and fixed in cvs

jenglish added on 2007-10-22 11:52:34:
Logged In: YES 
user_id=68433
Originator: NO

I'm not the right person to fix this; the BWidget code is beyond me.  Damon?

pointsman added on 2004-09-21 04:55:12:
Logged In: YES 
user_id=13222

Forgot to re-open.

pointsman added on 2004-09-15 06:32:13:
Logged In: YES 
user_id=13222

With current BWidget head, I still see the problem. The
point is, that a Combobox, with -editable false which was
-state disabled and later got configured to -state normal
didn't take the focus, while tabbing.

Please try the test script from an early comment by me:
package require BWidget

entry .w1
ComboBox .w2 -editable false -values {one two} -state disabled
entry .w3
ComboBox .w4 -editable false -values {one two}

pack .w1 .w2 .w3 .w4
focus .w1

.w2 configure -state normal

Try tabbing throu the widgets: the first one does not take
the focus    although both ComboBoxes have (after the .w2
configure -state normal) exactly the same settings.

hobbs added on 2004-09-15 06:30:16:
Logged In: YES 
user_id=72656

It looks like the code in combobox.tcl conflicts with the
focus code in widget.tcl that checks the -editable state.

hobbs added on 2004-09-15 04:39:28:
Logged In: YES 
user_id=72656

a non-editable combobox can be tabbed into in the head.

pointsman added on 2003-07-18 02:28:59:
Logged In: YES 
user_id=13222

To make my report even clearer, here a short script, which
demostrates the problem:

package require BWidget

entry .w1
ComboBox .w2 -editable false -values {one two} -state disabled
entry .w3
ComboBox .w4 -editable false -values {one two}

pack .w1 .w2 .w3 .w4
focus .w1

.w2 configure -state normal


Try tabbing throu the widgets: the first one does not take
the focus    although both ComboBoxes have (after the .w3
configure -state normal) exactly the same settings.

pointsman added on 2003-07-03 23:15:08:
Logged In: YES 
user_id=13222

A bit code diving showed, that there is in fact code, which
is intented to provide the behaviour, i wand (combobox takes
focus while tabbing, even if -editable false). The problem
is the following:

If the combobox is -state disabled, the widget doesn't take
the focus. 

For a [$combobox configure -editable false] call, there is
code in ComboBox::configure which ensures, that the entry
takes the focus, even if the new -editable value is false.

But if one create a combobox with -state disabled -editable
false and later change -state to normal with configure,
there isn't special care, that the -takefocus of the entry
is set to 1. 

Something like this code added to ComboBox::configure seems
to do the trick:

    if { [Widget::hasChangedX $path -state] } {
        if { ![Widget::cget $path -editable]  && 
             ![string equal [Widget::cget $path -state]
"disabled"] } {
            Entry::configure $path.e -takefocus 1
        }
    }