Displaying a field scrollbar only when it's needed

Deploying to Mac OS? Ask Mac OS specific questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Displaying a field scrollbar only when it's needed

Post by Mag » Sun Mar 10, 2013 11:24 pm

Hi guys,

I've a project where the content of a locktext field is programmatically populated and want to display the scrollbar only where there is more text than the one you can see. Is there a way to learn if a scrollbar is needed in a field? I can't find a way to do this... any advice? :oops:

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: Displaying a field scrollbar only when it's needed

Post by sturgis » Sun Mar 10, 2013 11:39 pm

You can do something like:

Code: Select all

if the formattedheight of field "fieldname" > the height of field "fieldname" then
   set the vscrollbar of field "fieldname" to true
else
   set the vscrollbar of field "fieldname" to false
end if
Can do the same for hscrollbar and width of course if you have long unwrapping lines.

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Displaying a field scrollbar only when it's needed

Post by Mag » Mon Mar 11, 2013 12:05 am

Your code works great

Yesterday I spent a lot of time to accomplish this with no luck, so thank you so much sturgis!

Post Reply