Height Size of Multi-line Fields

Post Reply
the_wesley_watkins
Posts: 42
Joined: Wed Jul 29, 2015 3:53 pm
My devices: Ipad
Iphone

Height Size of Multi-line Fields

Post by the_wesley_watkins »

I am designing an application to practice vocabulary words. I am using a read only field to show the definition of the word and giving 4 buttons at the bottom as choices. Sometimes, the definition is longer than expected so the the text will go off of the screen. To combat this, I decided to make use of the Multi-line feature of fields. However, my problem with this is that:

If the field is to be multi-line, the height of the field must change. However, I am determining the height of the field before-hand, so it is impossible to determine the height until the definition is actually given.

Here is a sample of what the code looks like:
How can I keep the field position correctly in it's box but account for longer words?

Code: Select all

GRAPHICS
GRAPHICS CLEAR 1,1,1
SET ORIENTATION PORTRAIT
fontname$ = "Arial"
FONTsize = 25
maxx = SCREEN_WIDTH()
maxy = SCREEN_HEIGHT()
DRAW COLOR 0,0,0
DRAW FONT NAME fontname$
DRAW FONT SIZE FONTsize
FOR i = 0 TO 3
	DRAW LINE 0, (maxy/2)+(maxy/8)*i TO maxx, (maxy/2)+(maxy/8)*i
NEXT i

/*Working
fieldname$ = "definition"
TEXT$ = "This is the definition of a word"
sizex = TEXT_WIDTH(TEXT$) 
sizey = TEXT_HEIGHT(TEXT$) + 5
x = (maxx/2) - (sizex/2)
y = (maxy/4) - (sizey/2)
FIELD fieldname$ TEXT TEXT$ AT x,y SIZE sizex, sizey RO ML
FIELD fieldname$ FONT NAME fontname$
FIELD fieldname$ FONT SIZE FONTsize
*/

/*NOT Working
fieldname$ = "definition"
TEXT$ = "This is the definition of a word and the definition is really long so the code ends up failing"
sizex = TEXT_WIDTH(TEXT$) 
sizey = TEXT_HEIGHT(TEXT$) + 5
x = (maxx/2) - (sizex/2)
y = (maxy/4) - (sizey/2)
FIELD fieldname$ TEXT TEXT$ AT x,y SIZE sizex, sizey RO ML
FIELD fieldname$ FONT NAME fontname$
FIELD fieldname$ FONT SIZE FONTsize
*/
Also, just as a side question, what are the default widths and heights of a field? Thanks!

Post Reply