Little trick about lines and paragraphs

Eric Chatonet eric.chatonet at sosmartsoftware.com
Tue Nov 29 15:07:50 EST 2005


Hi All,

A little trick that can help:
The problem: you want to add a header in a text field and want the  
field scrolled to the beginning of the meaningful text in order that  
nothing seems to change for the user (the header is added but stays  
hidden). Off course, you want it to work cross-platform and, may be,  
with the fixedLineHeight set to false:

       local tHtmlText,tHeader,tHeight
       -----
       put the htmlText of fld "Display" into tHtmlText
       set the htmlText of fld "Display" to tHeader & cr & "<p></p>"  
& cr & tHtmlText
       repeat with i = 1 to the number of lines of tHeader
         add the formattedHeight of line i of fld "Display" to tHeight
       end repeat
       set the scroll of fld " Display" to tHeight

According to the field's width, even if a *line* in the header *takes  
2 or more usual lines*, the resulting scroll will be perfect :-)
The trick: the formattedHeight of any paragraph returns the height  
needed for all *usual* lines that make up the paragraph.

Best Regards from Paris,

Eric Chatonet.
----------------------------------------------------------------
So Smart Software

For institutions, companies and associations
Built-to-order applications: management, multimedia, internet, etc.
Windows, Mac OS and Linux... With the French touch

Free plugins and tutorials on my website
----------------------------------------------------------------
Web site        http://www.sosmartsoftware.com/
Email        eric.chatonet at sosmartsoftware.com/
Phone        33 (0)1 43 31 77 62
Mobile        33 (0)6 20 74 50 86
----------------------------------------------------------------




More information about the use-livecode mailing list