4 Replies Latest reply on Aug 27, 2009 1:52 PM by BetoBoton

    Button Changing with click



      Button Changing with click


      I have 7 Fields that is the result of a calculation.Showing the WeekDay, Day and Month (a text conversion of a resulting date in the calendar) 

      They show each day of the "current week" in a a 7 day calendar layout.

      This Layout has Previous-Current-Next week choice so the 7 buttons have their text value changed constantly with each hit of the 3 buttons (Previous-Current-Next week)


      What is fixed:


      First Day of the week to the 7th day are all object layout named HDay1 to HDay7


      What I want to do:


      If I click one of these buttons inside the script it calls I want to change the text ( WeekDay, Day and Month) to a different colour to tell that in this week the selected day I'm using is this one (4th day) Thursday for example (week starts on Monday ).


      I would like to change the Pen Width of the field to 2 points. 


      I was not able to find how to change layout attributes of a field via script!


      Some pointers here would be very much appreciated.



        • 1. Re: Button Changing with click

          As far as I know there's no way to change the pen width of a layout object. You could create separate layouts for each object you want the different pen width and just switch layouts, but that's an awful amount of work just to show some fields with a heavier border.


          You can change fill color, text color and text styles by using conditional formats.


          Here's an example.


          Create a conditional expression in the Conditional Format settings:


          Table::field = "x"


          And select a fill color or other format as you want.


          In your script use Set Field [table::field ; "x"] to enable the selected format and Set Field [table::field ; ""] to return it to its original settings.

          • 2. Re: Button Changing with click

            Thank you very much for that.

            Just in case someone finds this post later on.


            I took your suggestion and created a  field containing the WeekDayNumber (1 to 7)

            As the button is hit it sets this field to a number (1 to 7) according to the day button clicked.

            I used the conditional formatting with a formula where  with :selected_Week_Day = 1 than it changes the field colour, text etc etc (what is possible to change).


            On Exiting the calendar window the selected day is cleared up so next time we call the calendar the selected day will be today's date.


            I had never played with conditional formatting before, but it is a neat trick for a lot of cases where the visual info needs to change according to the data value.




            • 3. Re: Button Changing with click
                 You can even use conditional formatting on button objects. I use that trick to turn button text grey to give it a "disabled" look if current conditions would keep the script that the button performs from doing anything.
              • 4. Re: Button Changing with click


                Brilliant tip