How to show a (modal) window on top?

Hello

I have a main window A that opens window B (user clicks button to open it). Now I want to open a Window C from Windows B. I can see Windows C but it’s always between windows A and B even when I click on it. I played around with Frame Type and Behaviour > Default Location but all with the same described result. So my question is: How can I bring a window on top? Or is that just not possible?

macOS Catalina 10.15.7
Xojo Version 2021 - Release 2.1

Example how it looks like:

It sounds like window b is already set to be Modal. Try turning that off and showing Window C as modal.

Wow, quick answer! Yes, Windows B is modal, Windows C should be modal as well. Is that a problem?

It’s uncommon. You might try using ShowWithin for Window C, but my instinct is that you’re going to need to rethink your UI. macOS may not allow you to stack one modal window on top of another.

Ok, you’re right! It works if window B is not modal (f.e. set to movable window) and window C then is modal. That way window C is on top.
The point/problem then is that the user still can access window A while window B (no more modal) is opened. That shouldn’t be possible.

I’m currently developing on MacOS but the app runs also on Win and Linux. So I work on a solution that fits for all 3 OS.

You might want to reconsider your design then. Perhaps a page or tab panel that lets users move though various screens of data instead of relying on overlapping modal windows.

The logic of my app is fine and works as the user would expect it. Window C is a colorpicker that is used only in window B. Sure everything could be redesigned which would take me a lot of work and time! I know other dev environments where I can stack countless modals on top of each other. So then I guess just Xojo doesn’t work that way (stackable/hierarchical modals)

Well you gave me a solution to my answer and the clarification I can’t do it that way, thanks!

Oh well if it’s a color picker, does the built in one not work? You also might be able to use a floating window.

I have been stacking modals windows with RB/RS/Xojo since the beginning. It’s perfectly logical when that’s what’s called for. It works now with Xojo as it always has. It’s ColorPicker that doesn’t work. See my demo movie and feedback case #64906.Modal window demo movie

What i do in situations like that is Hide Window A hen B opens, and re-show A when B is dismissed.

-Karen

I don’t find that at all. In my experience, Window A cannot be accessed and clicks just beep until window B is closed.

In one of my application I open a Modal window to set my accounts (Preferences) and I can open above them an additional window to set SMTP settings (I added after, at the beginning my application was only to receipt email then only POP settings).

In WindowA (Main window) I do : WIndowB.ShowModal
and in WindowB I do : WindowC.ShowModal(WindowB)
ShowWithin(MyWindow) is replaced by Show(MyWindow) since API2 dsktopWindow.

WindowB is Movable Modal and WindowC is SheetWindow.

Edit : If I set WindowC as Movable Modal and in WindowB I do : WindowC.ShowModal : I obtain this

1 Like

In the design cases, it is always a good idea to read:
Human Interface Guidelines

more relevant link:
Windows and views

Thanks all for the different answers!
What I found out in between:

  • ShowModal still allows to access the window in the background (f.e. in windowA: windowB.showmodal → windowA is still accessible while windowB is open, EXCEPT windowB is defined as “Modal Window”). So it’s not really modal.
  • showWithin works only on Macs

I tried your nice example…
Couldn’t make this working “WindowC.ShowModal(WindowB)” as ShowModal doesn’t seem to have a parameter but looks equal to WindowB.ShowModal while ShowWithin is Mac only.
I assume in your app that the Window MyPopBarrier is still accessible/clickable while the Preferences is opened. I have this unwanted case based on your example. It just seems not to be possible to block Window A while Window B is opened except Window B is defined as Movable Modal but then you can’t open any other Window (C) on top of Window B. :frowning:

No, as my windows are Modal I can’t access the windows behind.
Here is a small exemple WindowsModal.

Edit : Set Window3 as MovableModal (like Window2) instead of SheetWindow and in the button of Window2 which opens Window3 write “Window3.ShowModal” instead of “Window3.ShowModal(Self)”

Edit2 : In my initial exemple (without doing the change above), add a Window4 to the project (default Document window).
Create an “Opening” event in Window1 and enter the code below :

Window4.Top = Window1.Top + 20
Window4.Left = Window1.Left + Window1.Width - 40
Window4.Show

This window4 will open but you won’t be able to access it if Window2 is open.
Now set Window2 as “Sheet Window” instead of “Movable Modal”. Relaunch and open Window2. You will be able to access Window4 (but now Window1).

Thanks a lot for your detailed description, appreciated! I played them through and understand them now. The case with SheetWindow is not applicable for my app as it covers the preview screen that is changeable by the window covering it. The case where the last window will be opened by showModal is the solution I was looking for, thanks a lot!