简体   繁体   中英

Disable an event for all widgets of a specific type in TCL/TK

I would like to disable an event for a specific type of widget in TCL/TK. Specifically, I don't want the mousewheel to change the selected item in a ttk::combobox. I found bind.widget <<event>> break can be used to unbind. I was able to successfully unbind a ttk::combobox using the following lines.

bind .cb <MouseWheel> break
bind .cb <4> break
bind .cb <5> break

I would like to do this for all ttk::combobox 's. I found it is possible with tkinter from this answer, so I am inclined to believe its possible with TCL/TK.

I have tried the following to no avail.

bind ttk::combobox <MouseWheel> break
bind ttk::combobox <4> break
bind ttk::combobox <5> break

I used the bind widget_type <event> procedure format from the manual which contains the lines below.

bind Entry <<Paste>> {puts Paste}
bind Entry <<Scroll>> {puts Scroll}

I found the problem to be ttk::combobox is not the class name. Changing ttk::combobox to TCombobox fixed the problem.

bind TCombobox <MouseWheel> break
bind TCombobox <4> break
bind TCombobox <5> break

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM