Resize a field to the width of its contents

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
andrewferguson
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 184
Joined: Wed Apr 10, 2013 5:09 pm

Resize a field to the width of its contents

Post by andrewferguson » Fri Oct 03, 2014 5:47 pm

Hi,
I have a field and I need a way for it to resize its width to the the width of text that is in the field. The text in the field could be any length, but will not span over multiple lines.
Any ideas?
Andrew

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10057
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Resize a field to the width of its contents

Post by FourthWorld » Fri Oct 03, 2014 5:55 pm

See the formattedWidth property in the Dictionary, e.g.:
set the width of fld 1 to the formattedWidth of fld 1
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

LCNeil
Livecode Staff Member
Livecode Staff Member
Posts: 1223
Joined: Wed Oct 03, 2012 4:07 pm

Re: Resize a field to the width of its contents

Post by LCNeil » Fri Oct 03, 2014 5:56 pm

Hi Andrew,

Try the following-

Code: Select all

set the width of field "your field" to the formattedwidth of field "your field
Kind Regards,

Neil Roger
--
LiveCode Support Team ~ http://www.runrev.com
--

*Richard beat me to it above :)

andrewferguson
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 184
Joined: Wed Apr 10, 2013 5:09 pm

Re: Resize a field to the width of its contents

Post by andrewferguson » Fri Oct 03, 2014 6:08 pm

Thanks very much, this is exactly what I was looking for!
Andrew

Post Reply