开发者

How to determine whether the cursor is inside a gtk.Menu?

开发者 https://www.devze.com 2023-03-05 10:55 出处:网络
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 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消