public cave.ui.Menu addMenu(string title, cave.ui.Menu menu = null) { var v = menu; if (!(v != null)) { v = new cave.ui.Menu(); } var m = v; var button = cave.ui.TextButtonWidget.forText(context, title); button.setWidgetPadding(context.getHeightValue("1mm")); button.setWidgetPaddingHorizontal(context.getWidthValue("3mm")); button.setWidgetBackgroundColor(cave.Color.forString("#BBBBBB")); button.setWidgetClickHandler(() => { cave.ui.PopupMenu.showBelow(context, (Windows.UI.Xaml.UIElement)button, m); }); box.addWidget((Windows.UI.Xaml.UIElement)button); return(v); }
public static void showBelow(cave.GuiApplicationContext ctx, Windows.UI.Xaml.UIElement w, cave.ui.Menu menu) { if (!(w != null)) { return; } if (!(menu != null)) { return; } var widget = w; var context = ctx; var pm = new Windows.UI.Xaml.Controls.MenuFlyout(); var array = menu.getEntries(); if (array != null) { var n = 0; var m = array.Count; for (n = 0; n < m; n++) { var entry = array[n]; if (entry != null) { var i = new Windows.UI.Xaml.Controls.MenuFlyoutItem(); i.Text = entry.title; i.Click += (sender, e) => { entry.handler(); }; pm.Items.Add(i); } } } pm.ShowAt(widget, new Windows.Foundation.Point(0, Widget.getHeight(widget))); }