void HandlePopup(SolutionTemplate template, uint eventTime) { var engine = Platform.IsMac ? Xwt.Toolkit.NativeEngine : Xwt.Toolkit.CurrentEngine; var xwtParent = Xwt.Toolkit.CurrentEngine.WrapWidget(templatesTreeView); engine.Invoke(() => { if (popupMenu == null) { popupMenu = new Xwt.Menu(); } ClearPopupMenuItems(); AddLanguageMenuItems(popupMenu, template); Gdk.Rectangle rect = languageCellRenderer.GetLanguageRect(); try { popupMenu.Popup(xwtParent, rect.X, rect.Bottom); } catch { // popup at mouse position if the toolkit is not supported popupMenu.Popup(); } }); }
void OnButtonPress(object o, Xwt.ButtonEventArgs args) { if (!args.IsContextMenuTrigger) { return; } args.Handled = true; var row = listView.GetRowAtPosition(args.Position); if (row != -1) { var menu = new Xwt.Menu(); var mi = new Xwt.MenuItem("Remove Row"); menu.Items.Add(mi); mi.Clicked += (sender, e) => RemoveSelectedRows(); menu.Popup(listView, args.X, args.Y); } }
void PopulateMenuAndRaisePopup(Gtk.Widget gtkWidget, string selectedText, ButtonPressEventArgs args) { popupMenu.Popup(); args.RetVal = true; }
protected void InitWidget(Xwt.Widget Widget, IXwtWrapper Parent) { Widget.MinHeight = this.MinHeight; Widget.MinWidth = this.MinWidth; Widget.WidthRequest = this.Width; Widget.HeightRequest = this.Height; if (this.BackgroundColor != "") Widget.BackgroundColor = Xwt.Drawing.Color.FromName(this.BackgroundColor); if (this.Font != "") Widget.Font = Xwt.Drawing.Font.FromName(this.Font); Widget.TooltipText = this.TooltipText; Widget.MarginLeft = this.MarginLeft; Widget.MarginRight = this.MarginRight; Widget.MarginTop = this.MarginTop; Widget.MarginBottom = this.MarginBottom; Widget.Sensitive = this.Sensitive; Widget.Visible = this.Visible; Widget.Cursor = this.Cursor; Widget.HorizontalPlacement = this.HAlign; Widget.VerticalPlacement = this.VAlign; if (this.ContextMenu != null) { Widget.ButtonPressed += (o, e) => { if (e.Button == Xwt.PointerButton.Right) { Xwt.Menu M = new Xwt.Menu(); this.ContextMenu.Subitems.ForEach(X => M.Items.Add(X.Makeup(Parent))); M.Popup(); } }; } WindowController.TryAttachEvent(Widget, "MouseEntered", Parent, this.MouseEntered); WindowController.TryAttachEvent(Widget, "MouseExited", Parent, this.MouseExited); WindowController.TryAttachEvent(Widget, "MouseMoved", Parent, this.MouseMoved); WindowController.TryAttachEvent(Widget, "GotFocus", Parent, this.GotFocus); WindowController.TryAttachEvent(Widget, "LostFocus", Parent, this.LostFocus); WindowController.TryAttachEvent(Widget, "ButtonPressed", Parent, this.ButtonPressed); WindowController.TryAttachEvent(Widget, "ButtonReleased", Parent, this.ButtonReleased); if (this.Name != "") { Parent.Widgets.Add(this.Name, Widget); if (Parent.GetType().GetField(this.Name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) != null) Parent.GetType().GetField(this.Name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).SetValue(Parent, Widget); WindowController.RegisterWidget(this.Name, Parent, Widget); } }