/// <summary> /// Shows the context menu for a TreeView. /// </summary> /// <returns><c>true</c>, if context menu was shown, <c>false</c> otherwise.</returns> /// <param name="tree">Gtk TreeView for which the context menu is shown</param> /// <param name="evt">The current mouse event, or <c>null</c>.</param> /// <param name="entrySet">Entry set with the command definitions</param> /// <param name="initialCommandTarget">Initial command target.</param> public static bool ShowContextMenu(this Gtk.TreeView tree, Gdk.EventButton evt, Commands.CommandEntrySet entrySet, object initialCommandTarget = null) { if (evt == null) { var paths = tree.Selection.GetSelectedRows(); if (paths != null) { var area = tree.GetCellArea(paths [0], tree.Columns [0]); return(Ide.IdeApp.CommandService.ShowContextMenu(tree, area.Left, area.Top, entrySet, initialCommandTarget)); } else { return(Ide.IdeApp.CommandService.ShowContextMenu(tree, 0, 0, entrySet, initialCommandTarget)); } } else { int x = (int)evt.X, y = (int)evt.Y; if (Platform.IsMac && tree.BinWindow == evt.Window) { tree.ConvertBinWindowToWidgetCoords(x, y, out x, out y); } return(Ide.IdeApp.CommandService.ShowContextMenu(tree, x, y, entrySet, initialCommandTarget)); } }