void OnPreviewButtonClicked(object sender, EventArgs e) { if (!TreeView.DebuggerService.CanQueryDebugger || PreviewWindowManager.IsVisible) { return; } if (!MacObjectValueTreeView.ValidObjectForPreviewIcon(Node)) { return; } // convert the buttons frame to window coords var buttonLocation = PreviewButton.ConvertPointToView(CoreGraphics.CGPoint.Empty, null); // now convert the frame to absolute screen coordinates buttonLocation = PreviewButton.Window.ConvertPointToScreen(buttonLocation); var nativeRoot = MacInterop.GtkQuartz.GetWindow(IdeApp.Workbench.RootWindow); // convert to root window coordinates buttonLocation = nativeRoot.ConvertPointFromScreen(buttonLocation); // the Cocoa Y axis is flipped, convert to Gtk buttonLocation.Y = nativeRoot.Frame.Height - buttonLocation.Y; // Gtk coords don't include the toolbar and decorations ofsset, so substract it buttonLocation.Y -= nativeRoot.Frame.Height - nativeRoot.ContentView.Frame.Height; int width = (int)PreviewButton.Frame.Width; int height = (int)PreviewButton.Frame.Height; var buttonArea = new Gdk.Rectangle((int)buttonLocation.X, (int)buttonLocation.Y, width, height); var val = Node.GetDebuggerObjectValue(); SetPreviewButtonIcon(PreviewButtonIcon.Active); DebuggingService.ShowPreviewVisualizer(val, IdeApp.Workbench.RootWindow, buttonArea); var metadata = new Dictionary <string, object> (); metadata["UIElementName"] = TreeView.UIElementName; metadata["ObjectValue.Type"] = val.TypeName; Counters.OpenedPreviewer.Inc(1, null, metadata); }