Graphics

 View Only
  • 1.  Code for 'center text in a text box vertically' needed

    Posted 02-01-2012 22:57
    Anybody have a bit of code that centers all the text in a text box.. i already have code on there to word wrap..

    thx


  • 2.  RE: Code for 'center text in a text box vertically' needed

    Posted 02-03-2012 03:59
    Chris,

    Let me ask this for clarification. What do you want? Do you want to always center the text that is typed in it's bounding area?

    -g

    #XPression


  • 3.  RE: Code for 'center text in a text box vertically' needed

    Posted 02-03-2012 04:03
    I've got 4 lines of text within a text box (no more than 140 characters).. coming from a database.. if i have only one line of text, have it centered.. if it's two lines of text, centered with word wrap.. i don't want the text squeezed.. 3 & 4 lines of text, centered and word wrapped..

    #XPression


  • 4.  RE: Code for 'center text in a text box vertically' needed

    Posted 02-03-2012 09:14
    @Chris:

    How does your script to word-wrap look like?

    #XPression


  • 5.  RE: Code for 'center text in a text box vertically' needed

    Posted 02-03-2012 21:36
    Dim maxWidth As Double

    Dim newText As String

    Dim line As String

    Dim strWord As String

    Dim list As Array

    maxWidth = 400 'maxWidth = Self.AutoSqueezeWidth

    If Self.GetTextWidthS(Text) > maxWidth Then

    list = Split(Text, " ", -1, 1)

    newText = ""

    line = ""

    For Each strWord In list

    If (Self.GetTextWidthS(line & strWord) > maxWidth) Then

    newText = newText & line & vbCrLf

    line = strWord & " "

    Else

    line = line & strWord & " "

    End If

    Next

    newText = newText & line

    Text = newText

    End If

     

    #XPression


  • 6.  RE: Code for 'center text in a text box vertically' needed

    Posted 02-05-2012 17:17
    unfortunately all the scripts i've been given don't work properly for this task. They work in design mode but not when taking data from a database.. if I have a 4 line data coming in i can adjust the Y so it's centered correctly for every 4 line.. but then when a 1 line (or 2 or 3)comes in it's not centered.. if I adjust it for a 1 line to be centered, then the 4 line is way off.. if I had an option to adjust the LEADING of a row in the sequencer that could be a workaround.. i'll have the 1 line centered and manually adjust leading on 2, 3 & 4..

    Perhaps if I had a expert teamview in to see what it looks like as I take the data in a proper fix will be found.

    regards

    ps.. thanks ross guys, I've been given a variety of scripts by them, they've been helpful..

    #XPression


  • 7.  RE: Code for 'center text in a text box vertically' needed

    Posted 02-07-2012 00:57
    ?
    ..........
    #XPression


  • 8.  RE: Code for 'center text in a text box vertically' needed

    Posted 02-07-2012 08:02
    @Chris:

    My idea for a solution. It is not tested but I think it is worth to give it a try.

    put your text box into an animationcontroller with 4 positions which presents the 4 possible Y-positions for 1 to 4 rows of text. with your script you are able to count the amount of rows. Take the amount of rows as a reference for the position of the animcontroller and jump to that postiion.

    Hope this helps. Give me a note.

    regards

    Tom

    #XPression