Menu

#293 BWidget breaks Tk entry behaviour

closed-fixed
bwidget (187)
5
2003-07-17
2003-04-12
Joe English
No

(Reported on comp.lang.tcl 17 Jan 2003, "BWidget and
the tab key",
<URL:
http://groups.google.com/groups?th=96f589108bee7873 > )

Normally in Tk, tabbing into an entry widget causes the
entry's content to be selected. After loading the
BWidget package, this no longer works.

Discussion

  • Joe English

    Joe English - 2003-04-12

    Logged In: YES
    user_id=68433

    Analysis of the problem:

    The Tk behaviour for Entry widgets is implemented as a
    special case in ::tk::TabToWindow:

    # from tk/library/tk.tcl:
    #
    bind all <Tab> {tk::TabToWindow [tk_focusNext %W]}
    # [ ... ]
    proc ::tk::TabToWindow {w} {
    if {[string equal [winfo class $w] Entry]} {
    $w selection range 0 end
    $w icursor end
    }
    focus $w
    }

    The BWidget library overrides this with a different binding:

    # from bwidget/init.tcl:
    #
    bind all <Key-Tab> {focus [Widget::focusNext %W]}

    where [Widget::focusNext] is (according to the comments)
    "Same as tk_focusNext, but call Widget::focusOK (instead of
    tk::focusOK)", and Widget::focusOK is "Same as tk_focusOK,
    but handles -editable option and whole tags list."

    Proposed fix:

    Change the BWidget (and possibly Tk) <Tab> and <Shift-Tab>
    bindings to generate <<TraverseIn>> and <<TraverseOut>>
    virtual events.

    Then redo the Entry-specific logic in tk::TabToWindow in a
    <<TraverseIn>> binding.

    This is also related to Tcllib bug #720024 "BWidget ComboBox
    claims selection on FocusIn"

     
  • Joe English

    Joe English - 2003-04-18

    Logged In: YES
    user_id=68433

    The attached patch changes BWidget's <Tab> and <Shift-Tab>
    bindings to generate <<TraverseOut>> and <<TraverseIn>>
    virtual events.

    It also adds a <<TraverseIn>> binding for the Tk [entry]
    widget (fixing this bug), and replaces the ComboBox
    <FocusIn> binding with a <<TraverseIn>> binding (fixing bug
    #720024).

    In addition: Currently, when a non-editable, empty ComboBox
    widget receives keyboard focus, it changes the widget
    background and foreground colors to make it look like
    something is selected. This feature has been removed: no
    other widget sets seem to do this, and it's hard to
    implement correctly with the new framework.

     
  • Joe English

    Joe English - 2003-04-18
     
  • Rolf Ade

    Rolf Ade - 2003-07-17

    Logged In: YES
    user_id=13222

    The patch by jenglish fixed the problem for me.

     
  • Joe English

    Joe English - 2003-07-17
    • status: open --> closed-fixed
     
  • Joe English

    Joe English - 2003-07-17

    Logged In: YES
    user_id=68433

    Patch refreshed and committed.