resize in browse mode
Lynch, Jonathan
BNZ2 at CDC.GOV
Tue Dec 28 17:33:32 EST 2004
The following script is a bit complex - but it does the following:
1) if you right-click on the main part of the field, it lets you drag
around the location of the field
2) if you right-click on one of the corners of the field, it lets you
resize the field from that corner
3) if the mouse is over one of the corners of the field, it changes to a
cross, to let you know you are over one of the corner handlers.
(apologies for the fact that I type lines out very far to the right,
making them look funny upon being word wrapped - if you paste it into a
script, it should look the way it is supposed to)
==============
local allowDrag
local allowResizeTL
local allowResizeTR
local allowResizeBL
local allowREsizeBR
local CHS
on mouseDown theButton
if theButton = 3 then
put 5 into CHS
if ((mouseH()-(the left of me)) < CHS) and ((mouseV()-(the top of
me)) < CHS) then
put (mouseH()-(the left of me)) & "," & (mouseV()-(the top of me))
& "," & (The right of me) & "," & (the bottom of me) into allowResizeTL
else if ((the right of me)-(mouseH()) < CHS) and ((mouseV()-(the top
of me)) < CHS) then
put ((the right of me)-(mouseH())) & "," & (mouseV()-(the top of
me)) & "," & (The left of me) & "," & (the bottom of me) into
allowResizeTR
else if ((mouseH()-(the left of me)) < CHS) and (((the bottom of
me))-MouseV() < CHS) then
put (mouseH()-(the left of me)) & "," & ((the bottom of
me)-mouseV()) & "," & (The right of me) & "," & (the top of me) into
allowResizeBL
else if ((the right of me)-(mouseH()) < CHS) and (((the bottom of
me))-MouseV() < CHS) then
put ((the right of me)-(mouseH())) & "," & ((the bottom of
me)-mouseV()) & "," & (The left of me) & "," & (the top of me) into
allowResizeBR
else
put (mouseH()-(the left of me)) & "," & (mouseV()-(the top of me))
into allowDrag
set the cursor to cross
lock cursor
end if
end if
end mouseDown
on mouseMove x,y
put 5 into CHS
if allowDrag <> empty then
set the top of me to Y-(item 2 of allowdrag)
set the Left of me to X-(item 1 of allowDrag)
else if allowResizeTL <> empty then
if ((item 3 of allowResizeTL)-X) > CHS*2 then
set the width of me to (item 3 of allowResizeTL)-(X-(item 1 of
allowResizeTL))
set the Left of me to X-(item 1 of allowResizeTL)
else
set the width of me to CHS*2
set the Left of me to ((item 3 of allowResizeTL)-CHS*2)
end if
if ((item 4 of allowResizeTL)-Y) > CHS*2 then
set the height of me to (item 4 of allowResizeTL)-(Y-(item 2 of
allowResizeTL))
set the top of me to Y-(item 2 of allowResizeTL)
else
set the height of me to CHS*2
set the top of me to ((item 4 of allowResizeTL)-CHS*2)
end if
else if allowResizeTR <> empty then
if (X-(item 3 of allowResizeTR)) > CHS*2 then
set the width of me to (X+(item 1 of allowResizeTR))-(item 3 of
allowResizeTR)
set the Right of me to (X+(item 1 of allowResizeTR))
else
set the width of me to CHS*2
set the right of me to ((item 3 of allowResizeTR)+CHS*2)
end if
if ((item 4 of allowResizeTR)-Y) > CHS*2 then
set the height of me to (item 4 of allowResizeTR)-(Y-(item 2 of
allowResizeTR))
set the top of me to Y-(item 2 of allowResizeTR)
else
set the height of me to CHS*2
set the top of me to ((item 4 of allowResizeTR)-CHS*2)
end if
else if allowResizeBL <> empty then
if ((item 3 of allowResizeBL)-X) > CHS*2 then
set the width of me to (item 3 of allowResizeBL)-(X-(item 1 of
allowResizeBL))
set the Left of me to X-(item 1 of allowResizeBL)
else
set the width of me to CHS*2
set the Left of me to ((item 3 of allowResizeBL)-CHS*2)
end if
if (Y-(item 4 of allowResizeBL)) > CHS*2 then
set the height of me to (Y+(item 2 of allowResizeBL))-(item 4 of
allowResizeBL)
set the bottom of me to (Y+(item 2 of allowResizeBL))
else
set the height of me to CHS*2
set the bottom of me to ((item 4 of allowResizeBL)+CHS*2)
end if
else if allowResizeBR <> empty then
if (X-(item 3 of allowResizeBR)) > CHS*2 then
set the width of me to (X+(item 1 of allowResizeBR))-(item 3 of
allowResizeBR)
set the Right of me to (X+(item 1 of allowResizeBR))
else
set the width of me to CHS*2
set the right of me to ((item 3 of allowResizeBR)+CHS*2)
end if
if (Y-(item 4 of allowResizeBR)) > CHS*2 then
set the height of me to (Y+(item 2 of allowResizeBR))-(item 4 of
allowResizeBR)
set the bottom of me to (Y+(item 2 of allowResizeBR))
else
set the height of me to CHS*2
set the bottom of me to ((item 4 of allowResizeBR)+CHS*2)
end if
else
if (((mouseH()-(the left of me)) < CHS) and ((mouseV()-(the top of
me)) < CHS)) or (((the right of me)-(mouseH()) < CHS) and
((mouseV()-(the top of me)) < CHS)) or (((mouseH()-(the left of me)) <
CHS) and (((the bottom of me))-MouseV() < CHS)) or (((the right of
me)-(mouseH()) < CHS) and (((the bottom of me))-MouseV() < CHS)) then
set the cursor to cross
set the lockcursor to true
else
unlock cursor
exit MouseMove
end if
end if
end mouseMove
on mouseLeave
unlock cursor
end mouseLeave
on mouseUp
put empty into allowDrag
put empty into allowResizeTL
put empty into allowResizeTR
put empty into allowResizeBL
put empty into allowResizeBR
unlock cursor
end mouseUp
on mouseRelease
mouseUp
end mouseRelease
More information about the use-livecode
mailing list