Doing my own geometry

J. Landman Gay jacque at hyperactivesw.com
Thu Feb 7 13:51:38 EST 2008


Steve Checkley wrote:
> Hi Jacque,
>  
> Unfortunately, I've deleted the original handlers and gone back to
using Rev's own geometry manager.
> 
> I'd placed a button in the bottom right of the window and turned on
live resizing.
> 
> In pseudocode, the button's script ran along the lines of:
>  
> on mouseDown
>    repeat while the mouse is down
>        set the rect of this stack in relation to the mouseLoc (fixing min and max rects)
>    end repeat
> end mouseDown
>  
> on resizeStack
>     lock screen
>     -- geometry script in here
>     unlock screen
> end resizeStack

A big bottleneck here is using a mouseDown handler, which you don't 
need. Also, "repeat while the mouse is down" is not a great idea in 
Revolution. Polling the mouse is very slow and taxes the CPU, and there 
is almost always a better way to manage things. See an explanation here:

  <http://www.hyperactivesw.com/polling.html>

At any rate, a resizeStack handler manages all the mousedown stuff for 
you as well as locking and unlocking the screen. It is also unnecessary 
to set the rect of the stack because when the user drags the resize 
button the rect is set automatically. You don't need to deal with any of 
those things, all you need to do is catch the resizeStack message and 
adjust the geometry when it happens.

You'll only need one handler, something like this:

on resizeStack x,y
   set the bottomright of btn "fakeCloseBox" to x,y
end resizeStack

That's it. The resizeStack message passes two parameters that represent 
the current horizontal and vertical dimensions of the bottom right 
corner of the window. All you need to do it set your button to that 
location. This should be very fast, whether liveResizing is turned on or 
off.

-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com



More information about the use-livecode mailing list