Scrolling List Field/Table

Peter Haworth pete at lcsql.com
Mon Nov 19 13:54:05 EST 2012


I'm almost afraid to say this but itlooks like this is pretty easy to do
with variable spaced fonts too.

I did a simple test with an input field, an output scrolling list field,
and a button with the following code:

on mouseUp
   put the hilitedLine of field "Output" into tLine
   put the formattedwidth of field "Input" into tWidthIn
   put 100 into tWidthOut
   subtract tWidthIn from tWidthOut
   set the tabstops of line tline of field "Output" to tWidthOut & comma &
100
   put tab & field "Input"& tab & tLine into line tLine of field "Output"
end mouseUp

The text in the input field ended up right justified in the the hilited
line of the scrolling list field.  I'll no doubt have to deal with some
corner cases but I think I have right justified columns in my scrolling
list field.  Very cool!

Pete
lcSQL Software <http://www.lcsql.com>



On Mon, Nov 19, 2012 at 8:45 AM, J. Landman Gay <jacque at hyperactivesw.com>wrote:

> If you do go with a monospaced font, the alignment isn't too hard. For the
> right-aligned columns, just run the content through this ancient HC
> function before putting it into the field:
>
> function rightAlign theText,theWidth -- width of column in chars
>   put char 1 to theWidth of theText into theText
>   put char 1 to (theWidth-length of theText) of "                   "
> before theText -- or "after" for left-aligned
>   return theText
> end rightAlign
>
> Use enough spaces between the quotes to cover the column width, for worst
> cases.
>
> Or there's probably a better way now using the format function.
>



More information about the use-livecode mailing list