From: Armin Roehrl Date: 2001-11-10T07:42:26+09:00 Subject: [ruby-talk:24810] Ruby-Tk; feature/bug/misunderstanding? mouse-location during when a key is pressed in the presence of TkMenubutton Hi, I think the following is best explained with code. Can s.b. reproduce that error? Thanks a lot for your time and help, Armin 1st example: All works as you expect. When pressing "d", a small rectangle appears at the location the mouse-is pointing to right now. -- require 'tk' root=TkRoot.new{title "Bug or Feature or Misunderstanding?"} canvas = TkCanvas.new(root) canvas.pack root.bind('Any-Key-d', proc{|e| TkcRectangle.new(canvas, e.x,e.y,e.x-5, e.y-5)}) Tk.mainloop -- 2nd example: Same scenario, but now in the presence of a TkMenybutton When pressing "d", the small recantle is off by about 30 pixels; Is that the size of TkMenubutton? If yes, how can I determine that size? Also: if it is the size of TkMenubutton and I use "mouse" events, i.e. mouse-clicks why are the coordinates correct? no need to substract 30 or so; If you press "s" you see the correct and ok version. -- require 'tk' root=TkRoot.new{title "Bug or Feature or Misunderstanding?"} canvas = TkCanvas.new(root) menuline=TkFrame.new(root) menuline.pack("side"=>"top") TkMenubutton.new(menuline) { |mb| text "Zoom" underline 0 menu TkMenu.new(mb) { add 'command', 'label' => 'Zoom in', 'underline' => 0, 'command' => proc { p "in"; } add 'command', 'label' => 'Zoom out', 'underline' => 0, 'command' => proc { p "out" } } pack('side' => 'top', 'padx' => '1m') } canvas.pack root.bind('Any-Key-d', proc{|e| TkcRectangle.new(canvas, e.x,e.y,e.x-5, e.y-5)}) root.bind('Any-Key-s', proc{|e| TkcRectangle.new(canvas, e.x,e.y-30,e.x-5, e.y-35)}) Tk.mainloop -- Armin. ----------------------------------------------- Armin Roehrl, http://www.approximity.com "The best way to predict the future is to invent it." --Alan Kay