Google 網路論壇不再支援新的 Usenet 貼文或訂閱項目,但過往內容仍可供查看。

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

瀏覽次數:25 次
跳到第一則未讀訊息

Alexandru

未讀,
2017年12月13日 上午11:38:512017/12/13
收件者:
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

未讀,
2017年12月13日 上午11:48:362017/12/13
收件者:
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

未讀,
2017年12月13日 中午12:01:032017/12/13
收件者:
Thanks, I tried your tip but still, no change...

Brad Lanam

未讀,
2017年12月13日 中午12:03:082017/12/13
收件者:
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

未讀,
2017年12月13日 中午12:17:002017/12/13
收件者:
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

未讀,
2017年12月13日 中午12:21:392017/12/13
收件者:
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

未讀,
2017年12月13日 中午12:43:592017/12/13
收件者:
Cann't I just unbind the binding of the text window?

Brad Lanam

未讀,
2017年12月13日 中午12:57:272017/12/13
收件者:
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

未讀,
2017年12月13日 下午1:04:212017/12/13
收件者:
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 則新訊息