Hi Geoff,
When I plug this into my tester the text ends up at the top of the field.
iMac, Yosemite, LC6.7.1
on centreTextVertically tID
--THIS WORKS
-- put the effective textSize of fld id tID into tTextSize
-- put round (((tTextSize - 24) * 1/3)) into tOffset
-- put the formattedheight of char 1 to - 1 of fld id tID into
tFormattedHeight
-- put round((the height of fld id tID - tFormattedHeight) / 2) into
tVerticalMargins
-- put tVerticalMargins - tOffset into tTopMargin
-- put tVerticalMargins + tOffset into tBottomMargin
-- set the margins of fld id tID to 8,tTopMargin,8,tBottomMargin
--THIS WORKS
-- put the effective textHeight of fld id tID into tTextHeight
-- put item 2 of the loc of fld id tID into tfieldY
-- put the formattedRect of line 1 to - 1 of fld id tID into tFormatRect
-- put item 2 of tFormatRect into tCurrFormatTop
-- put tfieldY - tCurrFormatTop into tCenterField_To_TopTextDiff
-- put the number of lines of the formattedtext of fld id tID into
tNoOfLines
-- put (((tNoOfLInes div 2)) * tTextHeight) + (tNoOfLInes mod 2) *
(tTextHeight div 2) into tOffset
-- set the topMargin of fld id tID to the topMargin of fld id tID +
tCenterField_To_TopTextDiff - tOffset
--THIS WORKS
-- put the effective textHeight of fld id tID into tTextHeight
-- put item 2 of the loc of fld id tID into tfieldY
-- put the formattedRect of line 1 to - 1 of fld id tID into tFormatRect
-- put item 4 of tFormatRect - item 2 of tFormatRect into tFormatHeight
-- put tFormatHeight div 2 into tFormatHalfHeight
-- put item 2 of tFormatRect into tCurrFormatTop
-- put tfieldY - tCurrFormatTop into tCenterField_To_TopTextDiff
-- set the topMargin of fld id tID to the topMargin of fld id tID +
tCenterField_To_TopTextDiff - tFormatHalfHeight
--WITH THIS THE TEXT ENDS UP AT THE TOP OF THE FIELD
put the formattedrect of line 1 to -1 of fld id tID into tFormattedRect
set the topmargin of fld id tID to (the height of fld id tID - item 4 of
tFormattedRect + item 2 of tFormattedRect) div 2
end centreTextVertically
Don’t know why.
All the best
Terry
> On 20 Dec 2014, at 18:41, Geoff Canyon <[email protected]> wrote:
>
> I'm not seeing a
> way to break my two-line solution? What is the need for a more complex
> solution?
_______________________________________________
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