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
*/