I’m a bit stuck in developing an application with mono. So here’s my question: Is there a possibility to get the x / y position of a gtk.Button?
My layout is as follow:
- Window
- VBox
- HBox
- Button
I would like to have the position because I add a menu popup beneath this button. Currently it only shows up direct beneath the mouse cursor.
Thanks for your help ;).
You can get the x,y position of any object using the ‘Allocation’ member variable of the object. For example, if the button is called ‘button1’, than its x position would be at:
and its y position would be at:
You can find also the width and height that way, as well as many other relevant details, all in the ‘Allocation’ member.
Hope that helps!