Long URL in a field
J. Landman Gay
jacque at hyperactivesw.com
Sun Jun 13 23:08:15 EDT 2010
Emmett Gray wrote:
> In the HC version of a stack I've converted, I have a "notes" text
> field. The field has a vertical scroll bar, but not a horizontal one
> (and that's what I want). In HC, a long URL will wrap so you can see the
> whole thing on multiple lines. In Rev, it doesn't wrap so you can't see
> it all (although you can still select it by dragging to the right). Can
> this behavior be changed to be like in HC (i.e. force a line with no
> spaces to wrap)?
As Sarah said, Rev won't wrap these lines. If your field has no tab
stops in it, you can use a cheat. Set the tabstops of the field to 1.
Then use this in your handler:
replace slash with slash&tab in fld 1
Visually it looks almost right, you have to really squint to see those
1-character tabs. This way the engine will wrap the line automatically.
If you only want to wrap a single line in the field, just use something
like:
replace slash with slash&tab in line x of fld 1
If you need to use the URL for something, be sure to replace tab with
empty in the field contents before using it for anything:
get line x of fld 1
replace tab with empty in it
launch url it -- or whatever
If you need real, hard-coded carriage returns or you can't set the
tabstops to 1, this handler works on longer URLs that need to wrap over
more than 2 lines. (Sarah's works fine on 2-line wraps.)
on wrapField pFld -- pass name or number
set the itemdel to slash
put the width of fld pFld - (the leftmargin of fld pFld) - (the \
rightmargin of fld pFld) into tWidth
put 1 into x
repeat until the formattedwidth of fld pFld <= tWidth
if the formattedwidth of item 1 to x of fld pFld > tWidth then
put item 1 to x-1 of fld pFld & slash & cr after tText
delete item 1 to x-1 of fld pFld
put 1 into x
else
add 1 to x
end if
end repeat
put tText & fld pFld into fld pFld
end wrapField
--
Jacqueline Landman Gay | jacque at hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
More information about the use-livecode
mailing list