Consider the following code:
pack [label .l -text label]
menu .m
.m add command -label foo
bind .l <3> {after 500; tk_popup .m %X %Y}
Now, when right-clicking on the label, the popup menu appears but disappears immediately. The "after 500" is there to simulate some work that needs to be done before the menu can be drawn.
Investigation shows that the menu disappears when the mouse button is released before the menu is drawn. This is caused by the fact that, even though the menu is not yet drawn, the <ButtonRelease> event is directed to it, and it comes before the <Enter> event which sets the Priv(window) variable in menu.tcl.
I would propose to set Priv(window) also when the popup is drawn. This seems correct since, when drawing a popup menu, you at least want it to stay visible initially, event when the mouse cursor is not over it (note that this behavior is also consistent with Windows). See the attached patch, which solves this issue.
patch for menu.tcl