From: kero@...38c.nl (Kero van Gelder) Date: 2002-01-10T05:01:50+09:00 Subject: Re: Tk Popup Menu in a TkText widget >I will spare you most of the code, but here is the snippet I am using to >create and bind a right-click to do a popup menu: > > >ed_menu = MakeMenu.editor_bind_menu( ed ) >ed.bind('ButtonPress-3', > proc{ |x,y| > g = $mw.geometry > re = /\+(\d+?)\+(\d+?)/ > adj = re.match( g ) > ed_menu.popup( x+adj[0].to_i, y+adj[1].to_i ) > }, > "%x %y" ) > > >Is there a better way than parsing the geometry string to adjust for the >fact that |x,y| gives the pointer position relative to the upper-left >corner of the window, rather than the screen? I looked for possible >methods (Widget#methods) in my menu, its parent and the main window, but >found nothing that looked useful except geometry. Have a look at TkWinfo. TkWinfo.x(ed) or TkWinfo.root_x(ed) may produce the numbers you want. Bye, Kero. +--- Kero ------------------------------ kero@chello.nl ---+ | Don't split your mentality without thinking twice | | Proud like a God -- Guano Apes | +--- M38c ------- http://members.chello.nl/~k.vangelder ---+