AlertLoc

Sarah Reichelt sarah.reichelt at gmail.com
Wed Sep 7 19:48:09 EDT 2005


On 9/7/05, FlexibleLearning at aol.com <FlexibleLearning at aol.com> wrote:
> Window placement has caused some discussion recently, so I thought I'd  add
> my own ponderings to the pot...
> 
> on preOpenStack
>   set the loc of this stack to alertLoc()
>   checkWD
> end preOpenStack
> 
> 
> function alertLoc
> if "Win32" is in the platform  then
> if the mode of this stack is in "1,2" then put 30  into n # Toplevel titleBar
> height
> else put 22 into n #  Palette, modeless and modal titlebar height
> else
> if the mode of this stack is in "1,2" then put 23 into n # Toplevel titleBar
> height
> else put 16 into n # Palette, modeless and modal  titlebar height
> end if
> if the decorations of this stack =""  then put n-n into n
> get the windowBoundingRect
> put round(  (the width of this stack /2) + ((item 3 of it - item 1 of it) -
> the width of  this stack) / 2) + item 1 of it into x
> put round( (the height of this  stack /2) + ((item 4 of it - item 2 of it) -
> the height of this stack +n) / 3) +  item 2 of it into y
> return x,y
> end alertLoc
> 
> on checkWD
>   --| Ensure window is onScreen
> set the top of this  stack to max(item 2 of the WindowBoundingRect,the top of
> this  stack)
> set the right of this stack to min(item 3 of the  WindowBoundingRect,the
> right of this stack)
> set the left of this stack  to max(item 1 of the WindowBoundingRect,the left
> of this stack)
> set  the bottom of this stack to min(item 4 of the WindowBoundingRect,the
> bottom of  this stack)
> end checkWD
> 

Neat routine Hugh, but I would make one addition. When you are
checking to see if the window is on-screen, you use the
windowBoundingRect. In a standalone Mac app, the first 2 items of the
WBR are 0,0 but this does not allow for the Mac menu bar. So I always
check and set item 2 of the WBR to at least 44.

Cheers,
Sarah



More information about the use-livecode mailing list