Page 1 of 1

Irregular-shaped fields.

Posted: Sat Dec 12, 2009 11:44 pm
by edljr
Hi,

Is it possible for user-entered text to be auto-fitted into a non-square/rectangle text field? This code does not give me an error, nor does it result in any change.

Code: Select all

set the rect of fld "triangle1" to the rect of grc "triangle1"
Any help would be appreciated.

Thanks,
Ed

Re: Irregular-shaped fields.

Posted: Sun Dec 13, 2009 12:54 pm
by bn
Ed,
first I thought this can not be done, than I faked multiple one line fields and tested for the formattedwidth to advance to the next field. With Scott Rossi's suggestion of formattedRect it gave me the idea that you can get the formattedWidth of chunks as well. So I tried this in the script of a field with its alignement set to center (any other works also)

Code: Select all

on keyDown theKey
   put word 2 of the selectedLine into tLine
   if the formattedWidth of line tLine of me > 36 + (10*tLine) then -- adjust for the progression of width
      -- trying not to break words
      if (last char of line tLine of me <> " ") then
         put cr before last word of line tLine of me
         select after me
         pass keyDown
      else
         put return after line tLine of me
         select after me
         pass keyDown
      end if
   end if
   pass keyDown
end keyDown
This is by no means a complete solution. The user can go into any line and add text that will change the whole layout, also if the user deletes words in the middle of the text and so on. This is probably not the complete code behind the fancy page layout programs that can do these things. But depending on your needs you might get sufficient control over the triangular text layout.
Just one way to approach this.
regards
Bernd

Re: Irregular-shaped fields.

Posted: Sun Dec 13, 2009 5:31 pm
by edljr
Thanks, Bernd.

One could go crazy trying to prevent user-created havoc.

:-)

Re: Irregular-shaped fields.

Posted: Sun Dec 13, 2009 6:13 pm
by bn
Ed,
actually I wonder whether this is what you want to do. Do you want users to type into this field?
Are you trying something along the lines of the code I posted?

let us know how it goes.

regards
Bernd