Is it possible to ShowPopover a window from a DesktopToolbarButton? The following code:
Dim w As New winDispOptionsMain
w.ShowPopover(me.tiDisplayOpts2, DesktopWindow.DisplaySides.Right, False)
Compiler says: Parameter "parentControl" expects class DesktopUIControl, but this is class DesktopToolbarButton.
I can pass the actual DesktopToolbar, but then the popup displays out the right side of the parent window. I can’t seem to find in the documentation what UI controls are a DesktopUIControl. Thanks
That’s all we’ve got. It’s been an uphill battle to get that much.
Circling back around to solving your original problem, you could fake it if you know where the button is in the toolbar. Embed a dynamically created control just off view aligned with the toolbar button and attach the Popover to that. Destroy the anchor control when done.
This isn’t what I’d call reliable, especially looking at Tahoe changing things again; but it seems like it should work in theory?
That would require some calculations for the width of the text in different languages. For instance, my German text usually is longer than the English text. Also, you would have to check different versions of macOS. When did the toolbar icons get so small? After Big Sur?
I was not trying to misrepresent this as an easy or good idea, only a workaround.
Someone could file an issues tracker ticket feature request to be able to anchor to DesktopToolbarItem, but who knows what Xojo is cooking with Roadmap Item #3 being updating Desktop Toolbar.
Thanks @Tim_Parnell and @Beatrix_Willius for your replies. Good to know I wasn’t missing something obvious. I’m not that desperate to get this happening right now. I’ll wait to see what happens with the Roadmap, or just move this function to a BevelButton below the toolbar where I have some other BevelButtons with the next minor update of the app. I don’t think it’s worth opening an issue for this given the roadmap.
I’ve always been puzzled by the requirement of opening a popover from a DesktopUI control. Ideally there would also be a way to open one from arbitrary coordinates.
I was curious and asked Claude.ai how to solve the problem. I received four suggestions. Here’s one of them:
// Hidden anchor control
// First, add this property to your main window class:
// Property: PopoverAnchor As DesktopCanvas
// In your window's Opening event or constructor:
PopoverAnchor = New DesktopCanvas
PopoverAnchor.Left = WindowToolbar.Left + 80 // Adjust to position near your toolbar button
PopoverAnchor.Top = WindowToolbar.Top + WindowToolbar.Height // Adjust based on toolbar height
PopoverAnchor.Width = 1
PopoverAnchor.Height = 1
PopoverAnchor.Visible = False
Me.AddControl( PopoverAnchor )
// Then in your toolbar button's Action event:
Var w As New Container1 // Replace with your actual window class name
w.ShowPopover( Self.PopoverAnchor, DesktopWindow.DisplaySides.Right, False )
Thanks @Sascha_S for this post and trying it out. If I really needed this now I might consider it, but I’m sure the left position of the toolbar button will change over time with Xojo updates and me changing items in the toolbar, and also as Beatrix points out above, different languages can make different sized buttons. I’d rather not add something like this and forget to check that the popup works on macOS and Windows every time I update Xojo or make changes to the toolbar. I can’t see a way to get the left position of a DesktopToolbarButton to work around this. So thanks, I’d prefer to wait for Xojo to implement something.
The LLM code is also slightly wrong, as it isn’t setting a proper width and height, which is a key component of showing a popover correctly. You don’t just anchor it at a point, you anchor it at a rect, and it’ll adjust itself based on content requirements and screen space. But I’ve been trying to convince Xojo of this too, so maybe their code is coming from an LLM?
I built an example for arbitrary positioning of Popovers shortly after their release and added it to the forums as a reply somewhere here, but it’s probably worth uploading again.
This project contains a subclass of DesktopContainer with two additional methods:
Public Sub ShowPopover(parentWindow As DesktopWindow, x As Integer, y As Integer, displaySide As DesktopWindow.DisplaySides = DesktopWindow.DisplaySides.bottom, detachable As Boolean = True, animated As Boolean = True)
and
Public Sub ShowPopover(parentWindow As DesktopWindow, x As Integer, y As Integer, targetWidth As Integer, targetHeight As Integer, displaySide As DesktopWindow.DisplaySides = DesktopWindow.DisplaySides.bottom, detachable As Boolean = True, animated As Boolean = True)
It looks like the LLM Sascha used ripped off one of my methods with some modifications. Guess that’s another thing that annoys me about LLMs is that there’s no attribution, at least.
It will be a very long time before we can blindly adopt code (especially for Xojo).
I examine every generated code as closely as I can. Partly to look for potential problems with my own code, and partly to learn.
He’s not alone in his desire to keep this a human community as much as possible. It’s fine that you want to experiment with AI, but keep in mind that the original poster was looking for answers, not musings on the effectiveness of AI followed by an incomplete solution.
Your analysis on the other thread of whether Claude was better at coding than you are was actually interesting. Perhaps you could continue to update that thread with your further explorations of the subject, instead of spreading it amongst random threads?