Forum Discussion

els's avatar
els
Occasional Contributor
5 years ago

Is there a way to see if a text is trimmed?

I'm working on a test looking to check if the text shown is trimmed. Essentially say you have a text that says "Hello World! This is a small world!", based on the width allowed in that window the user will only see "Hello World! This is..." and I'm trying to check for that, but I don't see any properties for that or any possible functions.

 

Thank you.

3 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    There's not a built in function for doing so, no.  Typically, it's not really a "property" or such that's detectable.

     

    You can check the properties of the object to look for the truncated text and use that property.  Then use the aqString.Find method to check for "...".  If it finds it, it's truncated.

    • els's avatar
      els
      Occasional Contributor

      Hi. Thank you for your swift response. I imagined I could do it that way, but scanning through the text object properties, I would expect to use the Text property or perhaps the WPFControlText property in order to "grab" string value and I was hoping the ellipses (...) would be included in those properties, but sadly that's not the case.

       

      In every text property, I get the entire string and not the trimmed string so it's been confusing on how to test against that. I do have a TextTrimming property but it just states what type of trimming is used and not if that text is actually trimmed. 

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        It MIGHT be something in the general rendering in the browser or application.  Not a property of the object itself but how the technology acts by default.  I've seen some applications where, if the field is not wide enough, the text does NOT get trimmed but you have to scroll right (take a long URL in the address bar of your favorite browser for instance).

         

        So, this might not be something you can detect by the text of the text field/label itself.  Maybe it's a "native" object property.  It's probably going to take some investiation.

         

        The alternative is to do an image capture and OCR but I typically don't like those methods.