This is working for me but does fall apart when the field gets very small.
Also the font baselines change from Windows to both iOS and Android. Bug
12176 I have had many many variations of this task and this one is the best
I've found so far but I digress, I think there's bug because if the Yoda's
of LC can't get it right.... it's a bug.
Command CenterVert Obj -- for any control
Local tMargins , tHeight , tFheight , tSpace
put (0,0,0,0) into tMargins
try
put item 1 of the margins of obj into item 1 of tMargins
put item 3 of the margins of obj into item 3 of tMargins
catch SomeError
exit CenterVert -- Can't get margins?... do nothing
end try
put the height of obj into tHeight
try
put the effective formattedheight of char 1 to -1 of obj into tFheight
--for fields. Note the EFFECTIVE.
catch SomeError
try
put the formattedheight of control obj2 into tFheight -- for
buttons
catch SomeError
exit CenterVert -- Can't get the text height?... do nothing
end try
end try
if tFheight < tHeight then -- make top/bottom margins 0 if text is
clipped
put tHeight - tFheight into tSpace
put trunc(tspace/2) into tspace -- This trunc seemed to help at
extremes.
put tspace into item 2 of tMargins
put tspace into item 4 of tMargins
end if
set the margins of Obj to tMargins
end CenterVert
Ralph DiMola
IT Director
Evergreen Information Services
[email protected]
_______________________________________________
use-livecode mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode