Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

bind script break/continue

43 views
Skip to first unread message

Brad Lanam

unread,
Oct 13, 2015, 12:36:45 PM10/13/15
to
I have a bind for the arrow keys so that they can be used in the scrollable area to scroll the window up and down:

bind all <<PrevLine>> +[list ::scrolldata::arrowHandler $w $sb -1]
bind all <<NextLine>> +[list ::scrolldata::arrowHandler $w $sb 1]

The problem is if the focus is on a combobox in the scrollable area is active, then the mouse pointer is moved outside of the combobox, the arrow keys should ideally scroll the area, but instead *both* the scroll and the combobox arrow bindings are activated.

I tried 'return -code break', but that does not seem to help. A bare 'continue'/'break' cannot be used in the arrowHandler proc, it complains about not being in a loop. Removing the pre-pended + doesn't help.

Is there a proper way to deal with this?
I guess I will try resetting the focus (since I do know it's outside a combobox) next.



Brad Lanam

unread,
Oct 13, 2015, 1:48:20 PM10/13/15
to
A pain to deal with.

A procedure to move the 'all' binding as first:
proc _resetBinding { w } {
set bt [bindtags $w]
set idx [lsearch -exact $bt all]
set bt [lreplace $bt $idx $idx]
set bt [linsert $bt 0 all]
bindtags $w $bt
}

After the grid:
if { [winfo class $s] eq "TCombobox" } {
_resetBinding $s
set popdown [ttk::combobox::PopdownWindow $s]
_resetBinding $popdown
}

And the arrow key handler must have:
return -code continue
and
return -code break
in the appropriate places.

I don't know what other widgets have arrow keys and page up/down bindings, but they would need the same sort of handling when embedded in the scrollable area.

I guess the other method, which I haven't tried, is to bind to <Enter> on the other windows and reset the focus when the mouse has moved. This is actually probably messier.
0 new messages