Irregular-shaped fields.

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
edljr
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 56
Joined: Sun Oct 26, 2008 6:47 am
Contact:

Irregular-shaped fields.

Post by edljr » Sat Dec 12, 2009 11:44 pm

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
--
Ed Lavieri
three19
www.three19.com
--

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Re: Irregular-shaped fields.

Post by bn » Sun Dec 13, 2009 12:54 pm

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

edljr
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 56
Joined: Sun Oct 26, 2008 6:47 am
Contact:

Re: Irregular-shaped fields.

Post by edljr » Sun Dec 13, 2009 5:31 pm

Thanks, Bernd.

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

:-)
--
Ed Lavieri
three19
www.three19.com
--

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Re: Irregular-shaped fields.

Post by bn » Sun Dec 13, 2009 6:13 pm

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

Post Reply