richmond62 wrote: ↑Wed Dec 13, 2023 1:24 pm
Damage control should not consist of evasion.
And this means what exactly @richmond?
Doing this:
Code: Select all
on mouseUp
set the itemDelimiter to ","
put item 4 of the effective working screenRect into UD
put item 3 of the screenRect into LR
set the height of Stack "screen Stretch" to UD
set the width of Stack "screen Stretch" to LR
set the loc of stack "screen Stretch" to the screenLoc
end mouseUp
This is doing precisely what you are asking it to.
Actually, if I really wanted to be picky I would argue it is NOT doing a very good job as 7 pixels of the grab-bar at the top of the stack are obscured by the MacOS Menu bar:
Well, you could argue that - and that would be fine if your code wasn't wrong (for what you are *actually* wanting to do).
----
I hadn't actually meant to post my comment as it was unfinished - I had to go and deal with something else and was going to come back to this later and inadvertently hit submit instead of save draft.
However I was going to go on to say that this is (partly) why the proposed code is not having the desired effect - the center point you are using to place the window is not the center point of the working screenRect.
Further (the other part of the partly), you need to take into account Klaus's comment about taking into account the titlebar height of the window.
Like the rect/width/height of a stack, the loc is computed relative to the stack window's content area - i.e. the area of the stack in which you can draw things, not the area taken up when the OS has added its own 'furniture' such as titlebars and such.
Fortunately though, all the rect-related properties of a stack (rect/width/height/topLeft/topRight/bottomLeft/bottomRight/location) all take the 'effective' adjective which does the computations relative to the rect of the OS window the stack is appearing in.
So if you want a stack *and* its OS's furniture to fill the entire working area of the screen then you can do it in a single line:
Code: Select all
set the effective rect of stack "screen Stretch" to the working screenRect
If you want a stack's center to be at the center of the working screenRect then that does take a little more work (as, to be fair, this is probably not *that* useful):
Code: Select all
// This sets the center of the actual window (i.e. including window furniture) to the center of the working area of the screen
set the effective loc of stack "screen Stretch" to \
item 1 of the working screenRect + item 3 of working screenRect div 2, \
item 2 of the working screenRect + item 4 of the working screenRect div 2
// This sets the center of the window's content area (i.e. the bit where LC content is rendered) to the center of the working area of the screen
set the loc of stack "screen Stretch" to \
item 1 of the working screenRect + item 3 of working screenRect div 2, \
item 2 of the working screenRect + item 4 of the working screenRect div 2
As an aside 'the effective working screenRect' is a mobile device thing - on those platforms the 'effective' takes into account any on-screen keyboard if it is visible; adding 'effective' has no effect on desktop platforms.
The above should work on all three desktop platforms (with the small caveat that exceptionally exotic Linux window managers might not provide the necessary information to compute the OS furniture placement and sizes of windows and the desktop - but I strongly suspect these days that they are very rare and unlikely to be encountered).