Menu 使用Tk菜单命令而不是快捷键复制鼠标事件

Menu 使用Tk菜单命令而不是快捷键复制鼠标事件,menu,tcl,mouseevent,tk,Menu,Tcl,Mouseevent,Tk,这个问题与64位Win7上的Tcl/Tk 8.5.9(通过starkit运行时)和8.6(通过TkCon 2.7)有关,让我回到我编写的第一个Tk脚本。以下是: menu .menubar . config -menu .menubar menu .menubar.file -tearoff 0 .menubar add cascade -label "File" -menu .menubar.file -underline 0 .menubar.file add command -label

这个问题与64位Win7上的Tcl/Tk 8.5.9(通过starkit运行时)和8.6(通过TkCon 2.7)有关,让我回到我编写的第一个Tk脚本。以下是:

menu .menubar
. config -menu .menubar
menu .menubar.file -tearoff 0
.menubar add cascade -label "File" -menu .menubar.file -underline 0
.menubar.file add command -label "Test" -command {puts "Test"}
当以图形方式调用“Test”菜单命令时,我在stdout上得到了两次“Test”,就好像按钮释放事件是重复的一样。使用分配给此菜单命令的键盘加速器,按键命令按预期工作(即仅执行一次命令)

小部件配置选项如下所示:

% .menubar.file configure
{-activebackground activeBackground Foreground SystemHighlight SystemHighlight} {-activeborderwidth activeBorderWidth BorderWidth 0 1} {-activeforeground activeForeground Background SystemHighlightText SystemHighlightText} {-background background Background SystemMenu SystemMenu} {-bd -borderwidth} {-bg -background} {-borderwidth borderWidth BorderWidth 0 1} {-cursor cursor Cursor arrow arrow} {-disabledforeground disabledForeground DisabledForeground SystemDisabledText SystemDisabledText} {-fg -foreground} {-font font Font TkMenuFont {{Segoe UI} 9}} {-foreground foreground Foreground SystemMenuText SystemMenuText} {-postcommand postCommand Command {} {}} {-relief relief Relief flat flat} {-selectcolor selectColor Background SystemMenuText SystemMenuText} {-takefocus takeFocus TakeFocus 0 0} {-tearoff tearOff TearOff 1 0} {-tearoffcommand tearOffCommand TearOffCommand {} {}} {-title title Title {} {}} {-type type Type normal normal}

% .menubar.file entryconfigure 0
{-activebackground {} {} {} {}} {-activeforeground {} {} {} {}} {-accelerator {} {} {} {}} {-background {} {} {} {}} {-bitmap {} {} {} {}} {-columnbreak {} {} 0 0} {-command {} {} {} {puts "Test"}} {-compound compound Compound none none} {-font {} {} {} {}} {-foreground {} {} {} {}} {-hidemargin {} {} 0 0} {-image {} {} {} {}} {-label {} {} {} Test} {-state {} {} normal normal} {-underline {} {} -1 -1}
Mac上的8.5版本不会出现此问题

我在Python和Tkinter中看到了很多类似的内容,尽管我没有使用Python。我还想知道这是否与我的Win box上的鼠标有关,尽管在这台机器和Mac之间交换同一个鼠标不会改变上述行为

以前有人见过这个吗



更新:我碰巧注意到,当我允许菜单被删除,然后调用tearoff时,实际上创建了两个文件菜单窗口。当我将它们分开时(即拖动它们,使它们不会相互重叠),单独单击每个测试菜单项会导致仅调用一次命令。所以我创造了重复的菜单。(这是TkCon 2.7中的8.6.4/8.6.4。)

不能在win7-64上复制w/8.6.6。Tcl 8.6.4、Tk 8.6.4、win7也不能。如果问题是最后一个,不,我以前从未见过。重复的重叠菜单会导致问题。不幸的是,Tk将鼠标事件泄漏到较低的窗口。我已经有一个关于这个问题的错误报告。更新了关于这个问题的引用。不能在win7-64上复制w/8.6.6。也不能在Tcl 8.6.4、Tk 8.6.4、win7上复制。如果问题是最后一个,不,我以前从未见过。重复的重叠菜单会导致问题。不幸的是,Tk将鼠标事件泄漏到较低的窗口。我已经有一个关于这个问题的错误报告。更新了关于这个问题的引用。