Graphics

 View Only
  • 1.  Line wrap with limits and auto width control

    Posted 01-13-2020 16:09

    I reviewed (and originally posted to) this old thread:

    https://support.rossvideo.com/hc/en-us/community/posts/360040143591-Set-2-line-text-limit-with-word-wrap-enabled 

    However, as this didn't get any traction, I thought I'd start a new one with my question:

    I have a significant amount of visual logic running, and as a result, this script in the old thread doesn't work for (in part because the context of the text field I need to wrap is dynamically set via visual logic). I have tried to replicate the script, or my own variant of it in visual logic, but have encountered other issues, such as using the logic block to find a " " character to split lines doesn't return correctly if the start point if after the last space character. Also, the concatenate block does not allow me to add a CR/LF code into the text, or at least I haven't figured out how.

    Is there an easier way to constrain a text box to two lines high? Or does someone have a good example of a visual logic approach to this?

    In terms of pseudo code, I see it like this:

    If text.width < box.width, exit

    If text.width < box.wdth * 1.1, autosqueeze = true 'allows a small amount of squeeze on one line

    If text.width > box.width * 1.1, find split point at first line length or midpoint depending on length, insert a CR to make it two lines

    Any help appreciated!

    Thanks, Dave



  • 2.  RE: Line wrap with limits and auto width control

    Posted 01-14-2020 18:02

    I've been struggling with the same thing on and off, myself.

    You can enable Word Wrap with "textobject.WordWrap = true", and "textObject.WordWrapWidth = x"

    You can control the thing with cases based on "textobject.LineCount"

    My code is a mess at the moment, but hopefully that will get you somewhere. If I ever figure this out to my liking, I will share my code.

     


    #XPression


  • 3.  RE: Line wrap with limits and auto width control

    Posted 01-15-2020 16:32

    Thanks Nathan. I cannot believe the amount of effort I have put into trying to resolve this. There are several issues making this difficult, including the ones I noted above. I can get a basic script to work, but as I am linking the text from an xml file in visual logic, I cannot change the text field with a script, as it simply reverts back to the file version. I need it to stay linked to the file for dynamic name key changes. Attempts to copy the text field to another one and use that are stymied by the fact I cannot compare them in visual logic and ignore the CR/LF if it has been updated.

    I really need a solution for this. Either enabling word wrap with a limit, or a defined text box size that cannot be exceeded.

    If you have anything that works, I'd love to see it. 


    #XPression


  • 4.  RE: Line wrap with limits and auto width control

    Posted 01-15-2020 16:38

    I hope someone else can help you.

    I am not a programmer by any stretch and I gave up on using visual logic for basically anything very early on. It's just very clunky/buggy to me.


    #XPression


  • 5.  RE: Line wrap with limits and auto width control

    Posted 01-17-2020 11:13

    Hello Dave,

    in pure Visual Logic , you can try this :
    - "Text1" is the input text that is filled with datalinq . Auto squeeze and Word Wrap are disabled
    - "Text2" is a temporary item with word Wrap enabled.
    - "Text3" is the resulting text to be displayed with AutoSqueeze enabled

    The tricky part is to find a good value for Text2.WordWrap.Width when the input text width is greater than Squeeze width.
    The divide value to adjust WordWrap width can be from 1 to 2 .
    A value of 1 will favor squeezing over wraping
    A value of 2 will favor wraping over squeezing and will produce more than 2 lines quickly

    1.6 seems to be a good value, but it depends on the containing text.

    we can add on more test : if Text2 is more than 2 lines, try with a new adjust value on Text2_bis :


    Please note that this Visual Logic won't work everytime. And it seems that in the preview window the logic is not correctly displayed.
    More ideas are welcome to improve it.

    Here is the link to the project : https://drive.google.com/file/d/18I6m2rRPJoTmQ8KrSZOW4-DJVvyC6od2/view?usp=sharing

    Hope it helps,
    Antoine.


    #XPression