void TemplatesTreeViewButtonPressed (object o, ButtonPressEventArgs args) { SolutionTemplate template = GetSelectedTemplate (); if ((template == null) || (template.AvailableLanguages.Count <= 1)) { return; } if (templateTextRenderer.IsLanguageButtonPressed (args.Event)) { var menu = new Menu (); menu.AttachToWidget (this, null); AddLanguageMenuItems (menu, template); menu.ModifyBg (StateType.Normal, GtkTemplateCellRenderer.LanguageButtonBackgroundColor); menu.ShowAll (); MenuPositionFunc posFunc = (Menu m, out int x, out int y, out bool pushIn) => { Gdk.Rectangle rect = templateTextRenderer.GetLanguageRect (); Gdk.Rectangle screenRect = GtkUtil.ToScreenCoordinates (templatesTreeView, templatesTreeView.ParentWindow, rect); x = screenRect.X; y = screenRect.Bottom; pushIn = false; }; menu.Popup (null, null, posFunc, 0, args.Event.Time); } }