Stack offscreen solution

Bob Sneidar bobsneidar at iotecdigital.com
Wed Mar 30 13:03:08 EDT 2022


Sorry, a few artifacts from a previous version snuck in there. Here is the latest. 

on setWindowInScreen pStackName
   -- the stack rect
   put the rect of stack pStackName into tStackRect
   
   -- the rect of the screen the stack belongs to
   put the screen of stack pStackName into tScreenNum
   put line tScreenNum of the working screenrects into tScreenRect
      
   -- Check for window off screen
   IF item 1 of tStackRect < item 1 of tScreenRect THEN \
         set the left of stack pStackName to item 1 of tScreenRect
   IF item 2 of tStackRect < item 2 of tScreenRect THEN \
         set the top of stack pStackName to (item 2 of tScreenRect)
   IF item 3 of tStackRect > item 3 of tScreenRect THEN \
         set the right of stack pStackName to item 3 of tScreenRect
   IF item 4 of tStackRect > item 4 of tScreenRect THEN \
         set the bottom of stack pStackName to (item 4 of tScreenRect)
   
   -- the new screenRect
   return the rect of stack pStackName
end setWindowInScreen

Bob S


> On Mar 30, 2022, at 09:04 , Bob Sneidar via use-livecode <use-livecode at lists.runrev.com> wrote:
> 
> Hi all. 
> 
> For those dealing with the stack appearing offscreen, here is a handy handler for moving the stack so that it is fully visible to the screen it belongs to. Note that the screen it belongs to is determined by the loc of the stack. Maybe this should be added to the Master Library? 
> 
> Bob S
> 
> 
> on setWindowInScreen pStackName
>   -- the stack rect
>   put the rect of stack pStackName into tStackRect
> 
>   -- the rect of the screen the stack belongs to
>   put the screen of stack pStackName into tScreenNum
>   put line tScreenNum of the working screenrects into tScreenRect
> 
>   -- is stack within the screenRect
> 
>   -- Check for window off screen
>   IF item 1 of tStackRect < item 1 of tScreenRect THEN \
>         set the left of stack pStackName to item 1 of tScreenRect
>   IF item 2 of tStackRect < item 2 of tScreenRect THEN \
>         set the top of stack pStackName to (item 2 of tScreenRect + 42)
>   IF item 3 of tStackRect > item 3 of tScreenRect THEN \
>         set the right of stack pStackName to item 3 of tScreenRect
>   IF item 4 of tStackRect > item 4 of tScreenRect THEN \
>         set the bottom of stack pStackName to (item 4 of tScreenRect - 40)
> 
>   -- the new screenRect
>   return the rect of stack pStackName
> end setWindowInScreen
> 
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode




More information about the use-livecode mailing list