Deutsch   English   Fran├žais   Italiano  

View for Bookmarking (what is this?)
Look up another Usenet article

X-Received: by with SMTP id pf8mr1507635lbb.20.1446037402054;
        Wed, 28 Oct 2015 06:03:22 -0700 (PDT)
X-Received: by with SMTP id v42mr814933qge.9.1446037401436; Wed,
 28 Oct 2015 06:03:21 -0700 (PDT)
Path: ...!!!!!!wb3no5969421lbb.1!!t36ni33236qge.1!!m48no3027644qgd.0!!!not-for-mail
Newsgroups: comp.lang.tcl
Date: Wed, 28 Oct 2015 06:03:21 -0700 (PDT)
In-Reply-To: <>
Injection-Info:; posting-host=; posting-account=glPZ8goAAADztwA3kVEZPMKXCGydx5DU
References: <>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <>
Subject: Re: Bind <Leave> to Menu does not work
From: Alexandru <>
Injection-Date: Wed, 28 Oct 2015 13:03:21 +0000
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Am Mittwoch, 16. September 2015 00:44:49 UTC+2 schrieb Alexandru:
> Hi,
> any idea why binding the <Leave> event to a menu does not work?
> menu .popupmenu -tearoff 0
> bind .popupmenu <Leave> "puts *****"
> .popupmenu add command -label test
> tk_popup .popupmenu 100 100 0
> Thanks!


I have to come back with the same problem.=20

Does anybody have an idea, how to react to menu unpost and know if the user=
 really clicked before that on a menu entry or not?

I have this nice test script, with an very interesting behavior. Execute th=
e script and right click on the label. A popup menu will appear. Now either=
 left click in the menu or press the Escape key. When the user click in the=
 menu, a message is displayed. When the menu is unposted, another message i=
s displayed. There is a control variable "action" that should store what us=
er did, but this does not work right:

variable action ""

proc aftermenuclick {} {
	variable action "Click"
	tk_messageBox -message "This command is executed ONLY if user clicks in th=
e menu \nand AFTER the menu is unposted."
proc popup {w x y} {
	set wex [winfo rootx $w]
	set wey [winfo rooty $w]
	set x [expr {$x+$wex}]
	set y [expr {$y+$wey}]

	destroy .popupmenu
	menu .popupmenu -tearoff 0
	.popupmenu add command -label "Click here OR press Esc key" -command after=
	tk_popup .popupmenu $x $y 0

	variable action
	if {$action=3D=3D""} {
		set action "Escape"
	tk_messageBox -message  "Now I know the menu is unposted - but I don't kno=
w if user clicked in the menu or pressed Esc key. $action"
	set action ""

destroy .fr
pack [ttk::frame .fr]
pack [ttk::label .fr.l -text "Right click here to show the popup menu"]
bind .fr.l <3> {popup %W %x %y}

My system is Win 7 64 Bit. I know that the menu is managed by the OS but I =
really need to find a hack for this problem.

Many thanks!