Formatted text in a field.

James Hale james at thehales.id.au
Wed Apr 2 20:29:26 EDT 2014


Regarding paging of text.

I too have wanted to do this and have been flummoxed by the nature of text fields and their visual appearance capabilities. Unfair I know but still annoying.
I borrowed a solution from a stack on Livecodeshare (the name of which escapes me, not being at my desk.)
Firstly you will need to set the text height as fixed for the fields to get any consistency in the results.
Unless there is a large difference in text heights within the field I have found it safe to set a value that accommodates the largest and leave it at that. Sure the visual line spacing is increased, but not so as to make one concerned.
Secondly use two fields, one for each page, side by side, grouped with their tops at the same level.
The group's height is set to the height of the virtual page that you want, and both field's heights are set to the formatted height of the content of field 1. (At this stage, this is the same for both fields).
Now scrolling the group will scroll both fields in sync.
To get different page chunks on each page ( and allow for a blank page at the end of the second field) I simply added <return> Characters to the end of the second field. The number being equal to the group's height divided by the textheight setting of the fields. (Hence the requirement for fixed text height.)
Lastly I set the vscroll of the second field to the height of the group. (Remember its height was equal to the formatted height of field 1 but now has extra content and so can be scrolled.)
Now the second field (page 2) seems to start where the first field ends.
To page, just have a button that increases or decreases the vscroll of the group by the height of the group.
It works surprisingly well.

James



More information about the use-livecode mailing list