Tutorial explanation object lib for creating a multiplatform splitter?

Jan Schenkel janschenkel at yahoo.com
Mon May 10 17:30:04 EDT 2004


--- Kevin <nnoydb at excite.com> wrote:
> 
> 
> My definition follows a more "windows" slighted
> definition.  When one uses the file explorer the
> right border of the folder listed tree control is a
> splitter it splits and allows resizeing of the
> folder listing.
> 
> K
> 

Hi Kevin,

It looks like we're actually talking about the same
thing -- the only difference being the example I gave
was horizontal, and yours is vertical.
So when you look at the code in the horizontal
splitter, all you need to take into account is that
it's in the other direction.
In its most basic form, here's the code for a vertical
splitter button between two fields.

--

local sTrackingFlag, sMinLeft, sMaxRight

on mouseDown
  -- flip the tracking switch
  put true into sTrackingFlag
  -- and save the boundaries
  put the width of me DIV 2 into tMargin
  put the left of field "LeftField" + 16 + tMargin \
      into sMinLeft
  put the right of field "RightField" - 16 - tMargin \
      into sMaxRight
  -- and calculate my margin
end mouseDown

on mouseMove x,y
  if sTrackingFlag is true then
    -- first move this button within boundaries
    put min(sMaxRight,max(sMinLeft,x)) into tX
    put the location of me into tLocation
    put tX into item 1 of tLocation
    set the location of me to tLocation
    -- then update the field on the left hand side
    put the rect of field "LeftField" into tRect
    put the left of me into item 3 of tRect
    set the rect of field "LeftField" to tRect
    -- then update the field on the right hand side
    put the rect of field "RightField" into tRect
    put the right of me into item 1 of tRect
    set the rect of field "RightField" to tRect
  end if
end mouseMove

on mouseUp
  put false into sTrackingFlag
end mouseUp

on mouseRelease
  put false into sTrackingFlag
end mouseRelease

--

Hope this helped,

Jan Schenkel.

=====
"As we grow older, we grow both wiser and more foolish at the same time."  (La Rochefoucauld)


	
		
__________________________________
Do you Yahoo!?
Win a $20,000 Career Makeover at Yahoo! HotJobs  
http://hotjobs.sweepstakes.yahoo.com/careermakeover 


More information about the use-livecode mailing list