Question about "the screen" property of stacks...

Bob Sneidar bobsneidar at iotecdigital.com
Fri Jul 12 13:43:22 EDT 2019


Thanks Mark. I was playing with this to try and determine how to get a stack window to move to a position where it is fully visible on the screen it belongs to. Turns out not to be trivial, at least not for me. I worked out the math, and was feeling pretty proud of myself, until I realized the primary monitor may not be to the left of any secondary monitor. I then realized a second (or third) monitor may not even be right or left, but might be top or bottom! 

At this point my brain blew a fuse and I gave up. ;-)

There may be a command like get the screenLoc of screen 2, but I was not able to find it in the dictionary. That would be a handy edition. To that end, here is a function that will do it:

function getScreenCenter pStack
	-- pStack must be the name or the filename (not the short name) of a stack
	put the screen of pStack into tStackScreen
	put line tStackScreen of the screenRects into tScreenRect
	put item 1 of tScreenRect + ((item 3 of tScreenRect - item 1 of tScreenRect) /2) \
		into item 1 of tNewStackLoc
	put item 2 of tScreenRect + ((item 4 of tScreenRect - item 2 of tScreenRect) /2) \
		into item 2 of tNewStackLoc
	return tNewStackLoc
end getScreenCenter

Bob S


> On Jul 11, 2019, at 10:08 , Mark Waddingham via use-livecode <use-livecode at lists.runrev.com> wrote:
> 
> On 2019-07-11 17:17, Paul Dupuis via use-livecode wrote:
>> The screen of stack X returns the number of the monitor (the line
>> number for the screenRects) that the stack/window is on.
> 
>> If someone from the mothership can verify, I would be happy to open a
>> doc bug, update the dictionary, and generate a PR for an update to the
>> screen property Dictionary entry to clarify these two points.
> 
> The engine compares the content rect (not effective!) of the stack to the
> working area of each screen and takes the screen with which it shares the
> most area (the intersection of the stack's rect and the working area rect
> of the screen is a rectangle - and its the area of that which is used).
<snip>



More information about the use-livecode mailing list