[Mono-list] Right aligned popup menu
trampster at gmail.com
Sun May 22 05:05:07 EDT 2011
I have a button on the far right of an application. When clicked I want to
show a menu underneath the button but right aligned with it. (think google
This is what I have so far:
protected virtual void HandleMenuClicked (object sender, System.EventArgs e)
Menu menu = new Menu();
private void MenuPosition(Menu menu, out int x, out int y, out bool pushIn)
_menuButton.ParentWindow.GetOrigin(out x, out y);
int menuWidth = 75; //need to look up actual width.
x += _menuButton.Allocation.X - menuWidth;
y += _menuButton.Allocation.Y + _menuButton.Allocation.Height;
pushIn = true;
The problem with this is that I have hard coded the width of the menu. If a
longer menu entry was added, the font changed or theme changed then the
alignment will be wrong.
I tried looking up the width of the menu as follows:
int menuWidth = menu.Allocation.Width
This does not work as the menu has not been drawn yet and so the allocation
width is 1.
Any help will be greatly appreciated.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Mono-list