New issue with Monterey window top coordinates

Since I update my Mac to Monterey absolutely all my apps show the same issue. There is a gap between the window toolbar and the window contents. As soon as I resize the window the gap disappears though.

This is an example: 2021-11-12_12-54-27

I am using Xojo 2021r2.1 on Monterey (12.0.1)

The image for reference

1 Like

I recall some kind of hack fix when the toolbar was causing issues on Big Sur was to do this in the Window.Open event:

self.Height = self.Height

Does that help this issue?

1 Like

I had the same issue yesterday and sadly this fix for Big Sur won’t work on Monterey.

There is declare for this. I’m not in the office right now but it was mentioned here several times.

Can you post it here?

I’m having the same issue with two of my apps on Monterey (running on M1 MacMini from Intel build). The code above doesn’t fix it, but this does:

self.Height = self.Height +1
self.Height = self.Height -1

I have init code in the window constructors rather than open event handler, so place the above code at the end fixes the issue. Wondering if this is the best way to get around this issue.

The correct way is to set the NSWindow toolbarStyle

Declare it or use the MBS plugins.

https://developer.apple.com/documentation/appkit/nswindow/toolbarstyle

Thanks Christophe for the link. I wasn’t aware of the new ToolBar types that came with Big Sur.

However the problem I’m seeing occurs when apps are run on Monterey only and to me doesn’t look like an issue with selecting the correct ToolBar type. I’m happy with the default ‘Expanded’ type that Xojo selects. It’s just the objects on the window aren’t vertically aligned correctly for some of my ToolBar windows when run on Monterey. I haven’t been able to create a test app that isolates the issue. For now I’ll just refresh the window using my code above. Thanks

A couple of things.

  1. The “Expanded” toolbar is NOT the default for apps built against the macOS 11 SDK (like 2021rx apps are), so the Xojo Framework is setting this for you at some point during the window creation.

  2. This problem is not unique to Big Sur or Monterey, it’s been around for a while now. I solved it in one of my apps by removing the Toolbar and re-adding it. So I think it may have something to do with the initialization order of the window controls, or I guess I should now say DesktopWindow DesktopUIControls
 <shudders/>

Edit: As always spelling!

As ever, thanks for clarifying Sam. An issue with window control initialization order would make sense to me.

FWIW I tried creating a Xojo test app. I tried adding a couple of controls to the window, then adding a ToolBar. This didn’t reproduce the issue. In my previous test apps I added the ToolBar to the window first.

Thanks,

Mark

You’re welcome, but please understand that I do not know for sure, this is just a guess based upon the result of removing and re-adding the toolbar. It could be far more complicated, or even far simpler, but as I don’t have access to Xojo’s source code, I can’t take a peek.

I do hope that it helps in your case.

1 Like