Since I updated to Big SUR, when I open my APP, the APPs window top banner bar appears under the MACs Banner bar at the top of my MACs screen. I can just barely grab, with my mouse, the bottom of my APPs banner bar to drag it away. Once I have control of my apps window and move it around, it will not go back under the MAC banner, which is good.
To expand on Beatrix’s question, make sure you understand the difference between a Window.Bounds and Window.Top/Left/Height/Width.
The .Top etc properties refer to the CONTENT region of the window, that is WITHOUT the title bar etc. While the .Bounds refers to the position WITH the title bar, frame, etc.
So if you are setting the .Top property to say 0 or something, the title bar is likely to end up under the menu bar. There is a blog article which nicely describes all of this but I didn’t find it quickly to reference here.
Also look at the example section of the Window.Bounds property docs, because it warns you can’t directly modify a Bounds property. See the docs for a more complete explanation why and what you can do.
I added a messgagebox in my Window Open …“messagebox Form_HomeScreen.Top”
and it returned 50.
So I added a new line… “Form_HomeScreen.Top = 60”
And it works, my WindowTitle Bar is now just below the Menubar.
I guess the default is 50, I can’t see anyuwhere where I set TOP to 50.
Interesting Note: I have four of these apps on my MAC. All experienced the problem. I now fixed the one, rebuilt the executable, and its good. But now the other 3 are not having the orginal problem…
What I was trying to say before is .Top is the wrong way to set the window position, as it does NOT include the title bar (if the window has one) or the frame, etc.
It is better to set the .Bounds property. And as @Jon_Ogden mentioned, you should look at the Screen object’s .AvailableTop property as it already adjusts for things like the menu bar or whatever.
Now if you were NOT previously setting the Window.Top property and you were letting Xojo place the window for you, then consider creating a Feedback case if something is acting different under Bug Sir.
But if looking for an immediate work around, consider using .Bounds and Screen.AvailableTop if you want to properly compute how to place the window title bar just below the menu (assuming the user has the menu visible).
GetScreen is a module method I have that gets the current screen the window is in.
Now what I always found odd is that the AvailableTop property is supposed to be what is available outside the title bar. I found it does not seem to work that way.
I am not sure about using the .Bounds property for setting top Top. I do use the .Bounds property of the window to make sure my width and height are within the available viewing area. Here’s a method I use:
Public Sub CheckWindowHeight(Extends MyWindow As Window)
If MyWindow.Bounds.Height > MyWindow.GetScreen.AvailableHeight Then
Dim r as New REALbasic.Rect
r.Left = MyWindow.Bounds.Left
r.Height = MyWindow.GetScreen.AvailableHeight
r.Width = MyWindow.Bounds.Width
r.top = MyWindow.GetScreen.AvailableTop
MyWindow.Bounds = r
And I see it do set the Top property of the window here with the bounds. It’s been a while since I’ve looked under the hood and figured out what code is running when. Whatever I have now does seem to work…
There was a Xojo Blog article about this, but I can’t find it quickly. The point is that Window.Top refers to the CONTENT area while Window.Bounds refers to the OUTER frame including title bar or whatever. The docs for Window.Bounds have an example of properly setting .Bounds as a rectangle instead of a single property within the Window.Bounds object itself.
If what you do is save the Window.Top/Left property and restore that on the next run, that also “mostly” works. Unless the screen resolution changes, the user changes the menu bar configuration, dock position (affects .Left/.Right more than .Top), etc.
Yes. Agreed! It took me a long time to figure that out. Window.Top is the top of the CONTENT not the actual frame of the window. Bounds is absolutely the right way to do it. Some of my settings where I’m using .Top occur earlier in my code execution and I then use .Bounds later on. It’s been years since I’ve messed with all that!