原文:
10.19. How do I obtain Menus that do not tear off?
Nick Ing-Simmons outlined a couple of ways to achieve this result. The critical feature being the -tearoff => 0 configuration option of the Menu. In Nick's words: my $mb = $parent->Menubutton(...); # The button my $menu = $mb->Menu(-tearoff => 0); # Create a non-tearoff menu $mb->configure(-menu => $menu); # Tell button to use it. $mb->command(....);
Above is for clarity - you can loose $menu variable:
my $mb = $parent->Menubutton(...); $mb->configure(-menu => $mb->Menu(-tearoff => 0)); $mb->command(....);
译文:
10.19. 如何设置不让菜单被扯掉?
Nick Ing-Simmons总结了两个实现的方法,但关键都是要使用Menu组件的配置选项-tearoff=>0。
my $mb = $parent->Menubutton(...); # 菜单按钮
my $menu = $mb->Menu(-tearoff => 0); # 创建一个不能被扯掉的菜单
$mb->configure(-menu => $menu); # 让按钮使用它
$mb->command(....);
上面的例子只是为了说明的清楚,你也可以不使用$menu变量:
my $mb = $parent->Menubutton(...);
$mb->configure(-menu => $mb->Menu(-tearoff => 0));
$mb->command(....);