6 Replies Latest reply on Mar 20, 2012 9:32 AM by philmodjunk

    Width of a field display panel

    dzittin

      Title

      Width of a field display panel

      Post

      I have a field display and have to limit its phsyical size in a list. Most of the time the field contents is smaller than the panel, but not always.

      When field contents exceeds the display panel, I would like a conditional message to appear above the panel telling the user to click on panel, which is a button that causes another panel to pop up showing entire contents of the field.

      The problem I have is the logic for the conditional formating. Character count doesn't work because width varies (font=Georgia) even when the count is the same.

      I used the following to get the panel length in pixels:

      GetValue(Substitute(FieldBounds(Get(FileName);Get(LayoutName);"Tags::TagName"); " "; "¶");3) - GetValue(Substitute(FieldBounds(Get(FileName);Get(LayoutName);"Tags::TagName"); " "; "¶");1)

      Is there a function that tells me the field contents width in pixels or any other way to determine that a given contents will not fit a given display panel. FWIW, the display panel is a non-writable edit box.

      Thanks,

      -D

        • 1. Re: Width of a field display panel
          raybaudi

          "Is there a function that tells me the field contents width in pixels..."

          Yes, there is, but you'll need to know the height of that field, not the width.
          You'll need to give a name to the object ( field ) and, suppose that it is 1, this calculation will return the height:

          GetLayoutObjectAttribute ( 1 ; "height" ) 

          • 2. Re: Width of a field display panel
            dzittin

            I am not sure I understand how knowing the height of the field helps with a text "overflow".

            Raybaudi, correct me if I am wrong, but it seems you are helping me to describe the display panel. If this is true, I don't seem to have a problem determining the width of the display panel, what I need is the width of an arbitrary string (i.e. varying field contents) displayed in the panel and a comparator to determine that the string is too long to fit into the field.

            Thanks!

            -D

            • 3. Re: Width of a field display panel
              raybaudi

              I am not sure I understand how knowing the height of the field helps with a text "overflow".

              When a field contains more text than it can show, the size that increases is its height, not its width.

              If the initial size is 17 pixels, this becomes 32 with two lines of text and 47 with three lines of text.

              These new dimensions are, however, returned from that function only when the field is active.
              Then you'll need to use a trigger OnObjectModify.

              • 4. Re: Width of a field display panel
                philmodjunk

                To explain why the field's height increases, when the text is too wide to fit, it wraps to the next line--producing an increase in field height.

                • 5. Re: Width of a field display panel
                  dzittin

                  Ok, I understand. However, there is still a problem. What Raybaudi proposed works great as long as the field is edit'able. Mine is not. It displays data from a field that cannot be touched in this particular layout, only read by human eyes. From what I can tell it does not matter how long the field content is, there is no difference in the panel size and no difference in the GetLayoutObjectAttribute("n",height) return value. What I need is the size of the significant characters of the field, not the panel display since it cannot change size. A character count, of course does not work because of the font characteristics.

                  Am I missing something? In review, if the data exceeds the panel width (a rare, but not impossible) event, I want the user to be aware that a click on a panel (which is also a button) will cause a dialog to appear with the full field contents. 

                   

                  Thanks for the good ideas and I learned something too! :-)

                  • 6. Re: Width of a field display panel
                    philmodjunk

                    It took this thread before this method finally clicked for me. I'd tried before to use GetLayoutObjectAttribute to check the height and it hadn't worked for me either. The key is that you have to check for text wrap with this function at the time the cursor is in the field--where the field automatically expands out to the size needed to display the full text. It will not report a change in field height otherwise.

                    In your case, you'll need a script to test each value's fit in this field before hand and behind the scenes. An associated field can be set as a flag that identifies text that does not fit in this field. Exactly how you manage this depends on how different values get entered into this field in the first place.