I have开发者_开发知识库 a gtk.Menu
(which is being used as a popup) and I need to determine whether the mouse cursor is inside the confines of the menu.
I can get the mouse's position on the screen using this method. But how do I get the dimensions and position of the menu after calling menu.popup(...)
?
Looks like I didn't look close enough at some of the methods that gtk.Menu
provides.
It turns out that gtk.Menu
is a descendant of gtk.Widget
which has a method get_window
which returns the menu's underlying gtk.gdk.Window
.
From there, it's simply a matter of calling get_frame_extents()
which returns a gtk.gdk.Rectangle
with the position and size of the menu.
精彩评论