On 11/29/12 8:17 PM, I wrote:
I might try a mousemove handler that looks to see if the x
position was over one of the tabstops, and if the mouse was down, track
the mouseH and reset the tabstops. Maybe when I get some time I'll try
it.
In a fit of enthusiasm, I experimented. Here's a rough outline.
Make a field named "data" and a button named "Reset". Script of button
"Reset":
on mouseUp
set the traversalOn of fld "data" to false
set the autohilite of fld "data" to false
set the locktext of fld "data" to true
set the vGrid of fld "data" to true
set the tabwidths of fld "data" to 125,125,125,125,0
setupText
end mouseUp
on setupText
put "Color,Months,Days,ID Number" & cr into tText
replace comma with tab in tText
repeat 20
put any line of the colornames after tText
put tab & any line of the monthnames & " - " \
& any line of the monthnames after tText
put tab & any line of the weekdaynames & " - " \
& any line of the weekdaynames after tText
put tab & random(500000) & cr after tText
end repeat
put tText into fld "data"
-- header styling:
set the textstyle of line 1 of fld "data" to "bold"
-- set the spaceabove of line 1 of fld "data" to 5
set the spacebelow of line 1 of fld "data" to 8
set the padding of line 1 of fld "data" to 8
set the backgroundcolor of line 1 of fld "data" to "lightgreen"
set the bordercolor of line 1 of fld "data" to "forestgreen"
set the hgrid of line 1 of fld "data" to true
end setupText
That will set up some field properties and populate it with junk data. I
love the new "tabwidths" property, you don't have to do math any more to
figure out the tabstops.
Script of the field:
local sDragStop -- which tabstop is being changed; empty or zero if none
local sAdjustPx -- card loc to field loc adjustment amount
on mouseDown
put mouseDownOnTabstop() into sDragStop
put the left of fld "data" + the leftmargin of fld "data" - \
the hScroll of fld "data" into sAdjustPx
end mouseDown
function mouseDownOnTabstop -- are we close enough to a tab stop?
if word 2 of the mouseline > 1 then return 0 -- limit dragging to
header only
put the tabstops of fld "data" into tStops
put the mouseH into tX
put 4 into tSlop -- allow a little leeway
put 1 into tCount
repeat for each item i in tStops
put i + sAdjustPx into tStopH
if tX > (tStopH - tSlop) and tX < (tStopH + tSlop)
then return tCount
add 1 to tCount
end repeat
return 0
end mouseDownOnTabstop
on mouseMove x,y -- adjust tabstops
if sDragStop <= 0 then pass mouseMove
put the tabstops of fld "data" into tStops
put min(max(1,x - sAdjustPx),item (sDragStop + 1) of tStops - 6) \
into item sDragStop of tStops
set the tabstops of fld "data" to tStops
end mouseMove
on mouseUp
put 0 into sDragStop
if word 2 of the clickline > 1 then
-- process any non-header line clicks here, for example:
put the text of the mouseline
end if
end mouseUp
on mouseRelease
put 0 into sDragStop
end mouseRelease
Drag the vGrid lines around in the header. It could use some
enhancements, but that's the basic idea.
--
Jacqueline Landman Gay | jac...@hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode