Hi,
using:
Code: Select all
OpenWindow(0, 0, 0, 300, 300, "Center Screen", #PB_Window_SystemMenu)
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
shows that #PB_Window_ScreenCentered really does something.
Using:
Code: Select all
OpenWindow(0, 0, 0, 300, 300, "Center Screen", #PB_Window_SystemMenu)
CocoaMessage(0,WindowID(0),"center")
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
gives exactly the same result.
Doing a little bit more digging reveals this:
- The window is placed exactly in the center horizontally and somewhat above center vertically.
Such a placement carries a certain visual immediacy and importance.
This is the source:
https://developer.apple.com/reference/a ... 090-center
So the answer is: it's by
Apple's UI design
If you still want to have your window better "somewhat" centered you have to do it with code...
(quick and dirty...)
Code: Select all
ExamineDesktops()
Procedure TryToCenterTheWindow(window)
; not 100% centered on Y axis because of titlebar
Protected xPos = (DesktopWidth(0) / 2) - (WindowWidth(window) / 2)
Protected yPos = (DesktopHeight(0) / 2) - (WindowHeight(window) / 2)
ResizeWindow(window, xPos, yPos, #PB_Ignore, #PB_Ignore)
EndProcedure
OpenWindow(0, 0, 0, 300, 300, "Center Screen", #PB_Window_SystemMenu)
TryToCenterTheWindow(0)
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
This quick and dirty code doesn't take into account how many monitors are used...
Looking at both solutions Apple's placement really seems to be "nicer" to look at.
As aways:
Perception is reality...