Sliding Divider-Resizer Object

Gregory Lypny gregory.lypny at videotron.ca
Fri Jan 9 10:16:27 EST 2009


Thanks Phil,

Good stuff.  Timely too, as I'll be working on this tonight.

	Regards,

		Gregory

On Fri, Jan 9, 2009, at 9:52 AM, Phil Davis wrote:

> Here's something I used in a recent project. The adjustor object is a
> button, and it keeps the bottom of the "top" field a consistent  
> distance
> from the "bottom" field while allowing you to move the boundary  
> between
> them vertically.
>
> Other facts:
> - The button height = (top of "bottom" fld) - (bottom of "top" field)
> - the button is in a group, referred to as "the owner of the target".
> - the button has "uTopBounds" and "uBottomBounds" custom props telling
> how close (in pixels) it can get to the top of the top field & the
> bottom of the bottom field.
>
>
> -- "adjustor" button script:
> on mouseDown
>  -- params are <shortNameOfUpperField>,<shortNameOfLowerField>
>  _resizeFields "editItem","editItemDescription"
> end mouseDown
>
>
> -- handler in card script:
> on _resizeFields pTopField,pBottomField
>   -- prep
>   get the loc of the target
>   put item 1 of it into tMyH
>   put (item 2 of the loc of the owner of the target - item 2 of it)
> into tOffsetV
>   put the rect of fld pTopField into tTopRect
>   put item 2 of tTopRect + (the uTopBounds of the target) into  
> tTopBounds
>   put the rect of fld pBottomField into tBottomRect
>   put item 4 of tBottomRect - (the uBottomBounds of the target) into
> tBottomBounds
>
>   repeat until the mouse is up
>      put the mouseV into tMouseV
>      if (tMouseV < tTopBounds) or (tMouseV > tBottomBounds) then next
> repeat
>      lock screen
>      set the loc of the owner of the target to (tMyH,tMouseV+tOffsetV)
>      put the top of the owner of the target into item 4 of tTopRect
>      put the bottom of the owner of the target into item 2 of  
> tBottomRect
>      set the rect of fld pTopField to tTopRect
>      set the rect of fld pBottomField to tBottomRect
>
>      -- reposition bottom field label if there is one
>      get (pBottomField && "label")
>      if there is a field it then
>         set the top of fld it to the top of fld pBottomField
>      end if
>      unlock screen
>      wait 0 secs
>   end repeat
> end _resizeFields

Yes, most definitely!

On Fri, Jan 9, 2009, at 9:52 AM, Craig Newman wrote:
>
>
>> To
>> answer your question, Craig, the combined height and width of the two
>> fields is not constant, but that is not a problem because that sort  
>> of
>> resizing is handled by the geometry manager whenever the stack is
>> resized.
>>
>
> Surely. But once the fields are sized and located, your code should  
> run
> without issue, regardless of their location or rects. Its the beauty  
> of
> properties...




More information about the use-livecode mailing list