MessageDialog - dimming app windows

Hi all, trust you’re all well. Is there a way of dimming the rest of the application windows when a MessageDialog is displayed, which is now normal behaviour in MacOS? Maybe a Declare? Want my app to be as Mac friendly as possible so that users get the expected user experience. Many thanks, Dave.

My understanding is that Big Sur only dims the window that is displaying a sheet dialog. With Xojo, those are the ones that are displayed using MessageDialog.ShowModalWithin.

I have not seen an app that dims all its windows when a dialog is displayed.

2 Likes

Hi Paul, of course, you’re completely correct. However, I do need a function or call to dim all app windows in my instance. I’ll turf something up I’m sure. Dave.

The expected experience for users not on Big Sur would be the original behavior. I wouldn’t recommend going out of your way to adjust this.

1 Like

Good call, I’d have to check the installed MacOS version before doing something that a pre big-sur user would expect. Thanks Tim.

on macOS you may be able to put a Canvas or custom NSView on top of the content. Then put in some transparent gray color.
See CustomNSViewMBS class for example.

Or use code like this:

If view = Nil Then
  Dim win As NSWindowMBS = Self.NSWindowMBS
  
  view = New NSViewMBS(0, 0, Width, Height)
  
  win.contentView.AddSubView(view)
  
  view.wantsLayer = True
  view.autoresizesSubviews = True
  view.autoresizingMask = view.NSViewWidthSizable + view.NSViewHeightSizable
  
  Dim layer As CALayerMBS = view.layer
  layer.backgroundColor = CGColorMBS.CreateDeviceGray(0.3, 0.5)
  
Else
  
  view.isHidden = Not view.isHidden
  
End If

And make a new property view as NSViewMBS in the window.
You may hide/show the view as needed.

1 Like

You sir, as usual, are a legend. Thanks. Just the ticket.

1 Like