Bernd N and I have been through this -- there's no reliable way to this, unless 
you have a known number of lines, and a fixed point size, line height, etc.  
Bernd wrote a method that uses the pixel rect of the text via snapshot that can 
work.  My solution is to use buttons since those can display centered text, but 
that may not be an option for some implementations.

Regards,

Scott Rossi
Creative Director
Tactile Media UX/UI Design

> On Apr 1, 2016, at 9:08 PM, Sannyasin Brahmanathaswami <bra...@hindu.org> 
> wrote:
> 
>  
> lc8 16
> 
> I thought this should work to set the text of a field to vertical center
> 
> (in a behavior)
> 
> on mouseup
> set the textsize of me to 28
> put the formattedheight of me into tTotalTextHeight
> put ( ( the height of me - tTotalTextHeight ) / 2) into tTopBottomMargins
> set topmargin of me to tTopBottomMargins
> end mouseUp
> 
> But it doesn't and the vertical position varies depending on the number of 
> lines. field is 122 px high
> 
> 1 line# rides very high in the field
> 2 Lines # rides high but not so much
> 3 lines # centered perfectly vertically.
> 
> Futher testing reveals that I'm getting variations of responses from for the 
> formattedHeight in three different fields which
> 
> a) same number of lines
> b) same text size
> c) same text height
> d) different words
> 
> go stack url "http://wiki.hindu.org/screenshots/formattedheights.livecode";
> 
> if you do "put the formattedheight of selected object()"
> 
> into the msg box, and select the two fields you get different values for each 
> one, even though, obviously, they take exactly the same vertical space. And, 
> to make matters more interesting. if you set 0 margins in both fields, set 
> the top to the same, the text rides higher in the right field.
> 
> Am I doing something wrong or do we have something to report?
> 
> 
> 
> 
> 
> 
> 
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to