Getting Notch size/height in macOS with Declares

Hi there,

I’m interested in the Value “safeAreaInsets.top” from NSScreen (Apple docs). I already asked ChatGPT for code, but it does not work and I don’t understand the whole Declare stuff.

Is it possible to get this value without using plugins?

Cheers

If found a different solution. Maybe not perfect, but it works in my case:

Public Function GetNotchSize() As Integer
  Var size As Integer = DesktopDisplay.DisplayAt(0).AvailableTop - DesktopDisplay.DisplayAt(0).Top
  If size > 25 Then
    Return size
  Else
    Return 0
  End
End Function

Assuming your idea of using SafeAreaInsets is correct, here’s a project that gives you what you’ll need:

It’s not surprising that ChatGPT can’t handle this… there’s a bit of work to get to that info because Xojo does not expose the Handle of the screens.

2 Likes

Thank you, Greg. That’s exactly what I need. And thanks for the bonus with the Display name. That is useful for me, as well. :slight_smile:

I figured it might be the only way to tell more than one screen apart. I have two with the same dimensions but different names.

1 Like