Automatic new line in text field

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
lbtony
Posts: 35
Joined: Tue Apr 11, 2006 9:01 am

Automatic new line in text field

Post by lbtony » Thu May 04, 2006 1:42 pm

I have a text field with multiple lines. I want the cursor to go to the beginning of the next line when it reaches the end of current line. How to do this? At the moment, when the cursor reaches the end of a line, it just keeps going beyond the bound, I and can't find something in the prop settings to solve this problem. Thank you....

kray
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 56
Joined: Sat Apr 08, 2006 5:28 pm
Location: Eau Claire, WI
Contact:

Post by kray » Thu May 04, 2006 4:06 pm

set the 'dontWrap' of the field to true
Ken Ray
Sons of Thunder Software
Email: kray@sonsothunder.com
Web site: http://www.sonsothunder.com

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Thu May 04, 2006 4:07 pm

Open the property inspector of your field and uncheck the Don't Wrap checkbox. You can also use this syntax:

set the dontWrap of fld "Your Field" to false

Best regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

mcgrath3
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 149
Joined: Thu Feb 23, 2006 8:49 pm
Location: Bethel Park, Pittsbrugh, Pennsylvania USA
Contact:

Post by mcgrath3 » Thu May 04, 2006 7:16 pm

You can then select after line x of field y

and with the don'tWrap as false it will jump to the end of the line.

Tom
Tom McGrath III
Lazy River Software
3mcgrath@comcast.net

lbtony
Posts: 35
Joined: Tue Apr 11, 2006 9:01 am

Post by lbtony » Fri May 05, 2006 8:42 am

Unfortunately, unchecking the "don't wrap" field doesn't seem to work. it still keeps going to the right but doesn't start a new line.
P.S.
I used a Text Entry Field with multiple lines.
Do I also need some handlers to do this?

malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Location: Ostenfeld germany
Contact:

Post by malte » Fri May 05, 2006 8:47 am

Hi,

it will only break the line if the contents of the line is not a single word. As soon as there is a space in it it will work, but I think that is not what you are after...

What you want might be possible to script though...

A quick start out of the top of my head:

In the fields script

Code: Select all

on keyDown theKey
  if the formattedWidth of me > the width of me then
    put cr before char -1 of line -1 of me
    put theKey after line -1 of me
    select after line -1 of me
  else
    pass keydown
  end if
end keyDown
Hope that helps,

Malte

malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Location: Ostenfeld germany
Contact:

Post by malte » Fri May 05, 2006 8:49 am

Just checked and it works, given you type continiously and keep the text insertion point always at the end of the field. If you need a more sophisticated version, that takes care of changing the insertion point please let me know.

All the best,

Malte

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Fri May 05, 2006 8:57 am

Nice solution, Malte.

Now, fogive me being curiouse please, Tony, but what do you need it for?

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

lbtony
Posts: 35
Joined: Tue Apr 11, 2006 9:01 am

Post by lbtony » Fri May 05, 2006 9:31 am

Thanks Malte, thats really helpful....
The reason I need it is because I have a quite narrow text field on a quite narrow stack :( so on some lines it goes out of bound, but I want all the text to be displayed :P
to be honest, I'm a bit new to runrev, so I'm sorry if my questions sound naive :oops:

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Fri May 05, 2006 10:00 am

Hi Tony,

It is not naive at all, in fact your idea is very good and it is very understandable that you don't immediately think of the formattedwidth when you're new to Rev.

Enjoy the Revolution.

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Post Reply

Return to “Talking LiveCode”