5 Replies Latest reply on Mar 30, 2012 12:47 PM by philmodjunk

    Dynamic tab/object color change?

    jfalberg

      Title

      Dynamic tab/object color change?

      Post

      Is there any way to dynamically change the background color of a named tab object based on a field calculation?  If a certain value is zero I want to set to dark, and if greater than zero set to a specific lighter color.

        • 1. Re: Dynamic tab/object color change?
          philmodjunk

          You cannot use conditional formatting to change the fill color of a tab control like you can many other layout objects.

          You might be able to use either a field, button or block of layout text that changes fill color via conditonal format expression to create what appears to be a background color change. If you use a field, it can be an empty field and behavior settings can be set in the inspector to deny accesss. If you use a button, you can set the button to do nothing. Layout text can be a block of layout text containing nothing more than a space character.

          A calculation field that returns a container type might also be placed on the tab panel behind any fields and it's calculation could return the contents of a global container field filled with a dark rectangle or null.

          • 2. Re: Dynamic tab/object color change?
            jfalberg

            The more I think about it, what I really want to accomplish is disabling a tab if a certain calculated field is 0 so if I can at least change the appearance whether enabling to appear visible or not I think that would suffice.  I saw an example about conditional visibility but couldn't seem to figure how that worked.

            • 3. Re: Dynamic tab/object color change?
              philmodjunk

              You can set the onObjectModify script trigger on a tab control and then clicking different tabs will trip this trigger.

              You can use getLayoutObjectAttribute with the IsFrontPanel parameter to test to see which tab panel was just selected if you give each tab panel an object name. While the scripting gets a bit hairy, you can thus "disable" a tab panel selectively via a script plus a global variable that keeps track of the object name of the previously selected tab panel. If the script determines that the tab panel should be "disabled" it uses that variable with Go to Object to reselect the previous tab panel. If not, it updates the global variable with the name of the newly selected panel.

              You can use blank tab panel labels and replace them with layout text that use a conditional format to turns the text grey via a conditional format to show when a tab is "disabled".

              • 4. Re: Dynamic tab/object color change?
                jfalberg

                Another nice feature I'd like to accomplish is having merge field display on my tab labels.  Is there an easy way to accomplish this?  I suppose I could implement a transparent image so it looks like a normal rounded tab.

                • 5. Re: Dynamic tab/object color change?
                  philmodjunk

                  Yes, you can leave the tab labels blank in tab control set up and place layout text with merge fields where the tab label would ordinarily appear.

                  Sometimes this takes a bit of creativity to fit the merge text into the space available as the text won't properly disappear when a different tab is clicked if even one pixel of the layout text block extends up or to the right past the edges of the tab control.

                  Ron Cates showed me a trick that may help.

                  Say your merge text looks like this:

                  <<Table::FieldNameThat'sQuiteLong>>

                  If you select the text that's colored red while in layout mode, you can specify a font size that is very small, even one or two pixels while leaving the size of the outer <> shown in black the size you want for this data when you view it in browse mode. This shrinks the "real estate" taken up by the text block when you work with it in layout mode while still displaying in correct size when in other modes.