screenRect and screenLoc weirdness

Monte Goulding monte at appisle.net
Thu Jan 10 19:39:31 EST 2019



> On 11 Jan 2019, at 11:16 am, Knapp Martin via use-livecode <use-livecode at lists.runrev.com> wrote:
> 
> I was merely using that as an example. In my app I too place a toolbar in the topLeft corner of the screen by setting the topLeft of the stack to 0,0. On a single screen setup it works fine. But I've just discovered that on a multi-monitor setup as I've described, the toolbar isn’t even visible it’s so far off. So in this case 0,0 is not the top left corner of the main monitor. How so I arrive at that point? How do I determine the actual middle of the screen? Since I don’t understand all the dynamics of how these things are being determined I have not been able to arrive at a work-around to place things where I’d like them on the screen.

— set the topLeft of a stack to the topLeft of its screen below the menubar:
set the topLeft of stack “Foo” to item 1 to 2 of line (the screen of stack “Foo”) of the effective working screenRects

— set the topLeft of a stack to the topLeft of the main screen below the menubar
set the topLeft of stack “Foo” to item 1 to 2 of the effective working screenRect

— set the loc of a stack to the center of its screen
local tLoc, tRect
put line (the screen of stack “Foo”) of the screenRects into tRect
put item 1 of tRect + (item 3 of tRect - item 1 of tRect) div 2, \
      item 2 of tRect + (item 4 of tRect - item 2 of tRect) div 2 into tLoc
set the loc of stack “Foo” to tLoc

— set the loc of a stack to the center of the main screen
set the loc of stack “Foo” to the screenLoc

Hope these help! FWIW these should remain correct even if the general consensus is that the desktop space should have an 0,0  origin for the main screen.

Cheers

Monte





More information about the use-livecode mailing list