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

Text widgets in scroll frame -> scroll with mouse wheel does not work

25 views
Skip to first unread message

Alexandru

unread,
Dec 13, 2017, 11:38:51 AM12/13/17
to
Hi,

I have the special case of one scroll frame with any number of text widgets (with -state disabled) inside.

I would like to use the mouse wheel to scroll the scroll frame but that doesn't work when one of the text widgets gets the focus.

I'm guessing, that the text widget blocks the binding for the scroll frame. I tried to deactivate this by:

bind $mytestwidget <MouseWheel> {return -code continue}

but that didn't help.

Any ideas?

Regards
Alex

Gerald Lester

unread,
Dec 13, 2017, 11:48:36 AM12/13/17
to
If the text widgets are all disabled, then they should also have
-takefocus set to 0/no/off/flase.


--
+----------------------------------------------------------------------+
| Gerald W. Lester, President, KNG Consulting LLC |
| Email: Gerald...@kng-consulting.net |
+----------------------------------------------------------------------+

Alexandru

unread,
Dec 13, 2017, 12:01:03 PM12/13/17
to
Thanks, I tried your tip but still, no change...

Brad Lanam

unread,
Dec 13, 2017, 12:03:08 PM12/13/17
to
If you 'bind all', the bind command will propagate the binding
to all the child windows.

Of course your bind handler will now need to check
if it is in the scrollable window or in one of the scrollable
window's child windows.

I have...
set cont [winfo containing {*}[winfo pointerxy $sdvars(window)]]
if { ! [winfo exists $cont] } {
return -code ok
}
if { ! [string match $sdvars(window)* $cont] } {
return -code ok
}
I think I still have an rare bug where the winfo 'pointerxy' command
crashes. Have to figure that one out.

I also did the same thing for the page up/page down keys and arrow keys.

And it gets complicated if you actually have widgets such as comboboxes
where you don't want the frame to scroll.


Alexandru

unread,
Dec 13, 2017, 12:17:00 PM12/13/17
to
I'm not sure I understand.
I want to eliminate the scroll binding of the text widgets. I don't want to know wich window has focus.

Brad Lanam

unread,
Dec 13, 2017, 12:21:39 PM12/13/17
to
When you use 'bind all', all of the windows will receive the <MouseWheel>
event. The event handler will need to check which window it is in so
that it can determine whether to process the event or not.

Alexandru

unread,
Dec 13, 2017, 12:43:59 PM12/13/17
to
Cann't I just unbind the binding of the text window?

Brad Lanam

unread,
Dec 13, 2017, 12:57:27 PM12/13/17
to
Yes, it is certainly possible.
You would have to set the binding for every text window.

You may be able to be able to set a binding for the text window class.
% winfo class .t
Text
% bindtags .t
.t Text . all
but might have to reorder the bind tags for each text widget.

My opinion is that it is easier to use 'bind all' rather than
micro-managing the bindings of all the child widgets. 'bind all'
also has the advantage that it will continue to work if other
widgets are added to your scrolling frame in the future. I still
have to reorder the bindtags on comboboxes.

But either way works.

Brad Lanam

unread,
Dec 13, 2017, 1:04:21 PM12/13/17
to
Hmm.... 'bind all' might require that the bindtags on the text widget
be re-ordered, so it may be just as easy to reset the binding on every
text widget anyways.

I will have to test that with my scrolling package.
0 new messages