Discussion:
ttk::notebook mouse wheel event
Add Reply
alexandru
2024-12-29 12:14:39 UTC
Reply
Permalink
I searched my code for a reason why the ttk::notebook tabs are changed
upon mose wheel events.

Does anywone know how to deactivate this behavior?

No sure if there is another module causing this.

Many thanks
Alexandru
Rich
2024-12-29 16:25:46 UTC
Reply
Permalink
Post by alexandru
I searched my code for a reason why the ttk::notebook tabs are
changed upon mose wheel events.
Does anywone know how to deactivate this behavior?
No sure if there is another module causing this.
A basic ttk:notebook does not appear to bind to mouse wheel events in
any way:

$ rlwrap wish
% ttk::notebook .n
.n
% winfo class .n
TNotebook
% bind TNotebook
<Destroy> <Control-Key-ISO_Left_Tab> <Control-Shift-Key-Tab>
<Control-Key-Tab> <Key-Left> <Key-Right> <Button-1>

Therefore this behavior appears to be arising from some other module
you are using.
alexandru
2024-12-30 09:30:59 UTC
Reply
Permalink
Thanks. So that rulse out the idea, that the notebook does this by
default.
Of course I searched for other modules, that could do this mouse wheel
binding, but couldn't find anything until now.
nemethi
2024-12-30 14:00:54 UTC
Reply
Permalink
Post by Rich
Post by alexandru
I searched my code for a reason why the ttk::notebook tabs are
changed upon mose wheel events.
Does anywone know how to deactivate this behavior?
No sure if there is another module causing this.
A basic ttk:notebook does not appear to bind to mouse wheel events in
$ rlwrap wish
% ttk::notebook .n
.n
% winfo class .n
TNotebook
% bind TNotebook
<Destroy> <Control-Key-ISO_Left_Tab> <Control-Shift-Key-Tab>
<Control-Key-Tab> <Key-Left> <Key-Right> <Button-1>
Therefore this behavior appears to be arising from some other module
you are using.
This functionality was proposed for Tk 8.7 (and 9) by Harald Oehlmann
with TIP 591, and for these Tk versions it is now included in the core.
For earlier Tk versions it is not present in the core, but the
Scrollutil package includes it since its version 1.9. For this reason,
if your application invokes "package require scrollutil_tile" then it
will automatically activate the bindings that are responsible for the
navigation between the tabs via the mouse wheel.

Now, for some reason you don't want to have this handy feature. You can
deactivate it for all ttk::notebook widgets via

bind TNotebook <MouseWheel> ""
bind TNotebook <Shift-MouseWheel> ""

or just for an individual ttk::notebook $nb via

bind $nb <MouseWheel> break
bind $nb <Shift-MouseWheel> break

The above is for Windows, which to my knowledge is the platform you are
working on.
--
Csaba Nemethi https://www.nemethi.de mailto:***@t-online.de
nemethi
2024-12-30 14:05:58 UTC
Reply
Permalink
Post by nemethi
Post by Rich
Post by alexandru
I searched my code for a reason why the ttk::notebook tabs are
changed upon mose wheel events.
Does anywone know how to deactivate this behavior?
No sure if there is another module causing this.
A basic ttk:notebook does not appear to bind to mouse wheel events in
   $ rlwrap wish
   % ttk::notebook .n
   .n
   % winfo class .n
   TNotebook
   % bind TNotebook
   <Destroy> <Control-Key-ISO_Left_Tab> <Control-Shift-Key-Tab>
   <Control-Key-Tab> <Key-Left> <Key-Right> <Button-1>
Therefore this behavior appears to be arising from some other module
you are using.
This functionality was proposed for Tk 8.7 (and 9) by Harald Oehlmann
with TIP 591, and for these Tk versions it is now included in the core.
For earlier Tk versions it is not present in the core, but the
Scrollutil package includes it since its version 1.9.  For this reason,
if your application invokes "package require scrollutil_tile" then it
will automatically activate the bindings that are responsible for the
navigation between the tabs via the mouse wheel.
Now, for some reason you don't want to have this handy feature.  You can
deactivate it for all ttk::notebook widgets via
    bind TNotebook <MouseWheel> ""
    bind TNotebook <Shift-MouseWheel> ""
or just for an individual ttk::notebook $nb via
    bind $nb <MouseWheel> break
    bind $nb <Shift-MouseWheel> break
The above is for Windows, which to my knowledge is the platform you are
working on.
My posting was meant as an answer to the one by Alex, sorry!
--
Csaba Nemethi https://www.nemethi.de mailto:***@t-online.de
alexandru
2025-01-01 10:54:20 UTC
Reply
Permalink
Many thank Csaba, as always you are huge helper.

I will deactivate the binding.

This is why: My software makes use of mouse wheel a lot and it
interferes with the schange of tab in an anwanted manner.

The user moves the mouse around and it's not simple to pay attention to
the area of focus. So the mouse slides out of the current focus area and
hovers over some tabs triggering the change.

I observed this issue multiple times in the last months of support with
my customers.

A better kind of binding to mouse wheel for thabs can be found in
FireFox.
There, the wheels truelly scrolls the tabs without changing the active
tab.
Just imagine how big of a problem that would be in FireFox having the
same behavior as in Tcl/Tk.
Since the user constantly uses the mouse wheel, having to make sure that
the mouse pointer never unwantedly hovers over the tabs!

I really hope you could rethink this implementation and maybe switch to
how this feature works in FireFox.

Also, I can only hope the Tcl 9.0 has a way of working around this.

Happy new year to all!

et99
2024-12-31 02:16:46 UTC
Reply
Permalink
Post by Rich
Post by alexandru
I searched my code for a reason why the ttk::notebook tabs are
changed upon mose wheel events.
Does anywone know how to deactivate this behavior?
No sure if there is another module causing this.
A basic ttk:notebook does not appear to bind to mouse wheel events in
$ rlwrap wish
% ttk::notebook .n
.n
% winfo class .n
TNotebook
% bind TNotebook
<Destroy> <Control-Key-ISO_Left_Tab> <Control-Shift-Key-Tab>
<Control-Key-Tab> <Key-Left> <Key-Right> <Button-1>
Therefore this behavior appears to be arising from some other module
you are using.
This is ironic; I actually wanted this behavior for bwidgets notebooks, and to make it work on linux one binds to Button-4 and Button-5 to use the mousewheel. Perhaps something in your code is doing this too.

I posted an example of this in https://wiki.tcl-lang.org/page/notebook (last post at bottom) which mostly was to demonstrate a bwidget notebook with close buttons on each tab, but also included the mousewheel over the tabs for scrolling them as well.
Loading...