14 Replies Latest reply on Mar 6, 2010 6:32 AM by LeoB

    Conditional formatting for button click

    CarrieB.

      Title

      Conditional formatting for button click

      Post

      I have several fields I've made into buttons that only set the content of a different field. Is there a way to put conditional formatting on the button only after it has been clicked? To make it easier for the user to know which field he chose? There probably was a much better way to set this up, but I can't figure it out. :smileyhappy:

        • 1. Re: Conditional formatting for button click
          raybaudi
            

          Hi CarrieB.

           

          Yes, you can.

           

          The Set Field [ ] script step must be modified with something like this:

           

          Set Field [ YourField ; Let ( $color = Abs ( $color + 1 ) ; Case( $color ; "yourValueHere" ) )]

           

          The conditional formatting for that button must be:

           

          Formula = not IsEmpty ( YourField )

           

          The result will be that, clicking the button once, YourField will contain YourValueHere and the button will change its color; re-clicking will set YourField to empty and the button will return to its default color.

          • 2. Re: Conditional formatting for button click
            CarrieB.
              

            I'm sorry. I'm not following you. I'm fairly new at this and not yet very good at formulas and operators. =) If I modify the set field portion of my script, am I placing that info in the target field or calculated result?

             

            Thanks for your  help!

            • 3. Re: Conditional formatting for button click
              jsalzer_1
                

              Hi, Carrie,

               

              It sounds like you've already set up specialized fields for these buttons.  You can do something like this:

               

              Set all the fields to a value of 0.

               

              When the user clicks one of the fields, say Button1, have the script add a line for:

              SetField (Button1 ; 1)

              which changes the value of Button1 from 0 to 1.

               

              Then set up your conditions so that if Button1 = 1, you get the new color.

               

              That said, if you have 10 buttons and you only want the last one clicked to be colored, you'll have to set each script to go through the other 9 buttons and set them all to 0.

               

              I think this covers what you're looking for.  :) 

              • 4. Re: Conditional formatting for button click
                raybaudi
                  

                Hi CarrieB

                 

                > I modify the set field portion of my script...

                 

                Please, be clear: have you a button with only one step or a button that fires a script of more than one step ?

                 

                > am I placing that info in the target field or calculated result?

                 

                calculated result.

                • 5. Re: Conditional formatting for button click
                  CarrieB.
                    

                  Yes, I have buttons that fire a script with more than one step. Basically, it is setting other fields, but not changing layouts or displaying any dialog. But, I think I got it figured out. I just set a dialog to let the user know that they had chosen a recipient. Seems easier at this point. =)

                   

                  Thank you so much for your help!!

                  • 6. Re: Conditional formatting for button click
                    raybaudi
                      

                    I choose that way to solve your problem thinking that the button has only a step ( with that as a limitation ).

                     

                    So there are even simpler ways if your button fires a whole complex script.

                    • 7. Re: Conditional formatting for button click
                      CarrieB.
                         By simpler ways, do you mean using Custom Dialog? Or something simpler? =)
                      • 8. Re: Conditional formatting for button click
                        raybaudi
                           no, back to the topic, conditional formatting the button color.
                        • 9. Re: Conditional formatting for button click
                          CarrieB.
                            

                          I thought I would try to come back to this and give it a shot, but I'm still not having any luck. I do have 10 buttons, which are fields in a related table (also they are a calculated field). When you press on any of them, it runs a script that sets other fields and shows custom dialog based on the script parameter. When I try to configure a set field step to change the color, it always ends up giving me a message that it cannot perform that specific step because the field is not modifiable. Is this because it is a calculated field? Or because I changed the field to a button?

                           

                          Thanks!!

                          • 10. Re: Conditional formatting for button click
                            raybaudi
                              

                            CarrieB. wrote:

                             

                            When I try to configure a set field step to change the color, it always ends up giving me a message that it cannot perform that specific step because the field is not modifiable.


                            Hi CarrieB

                             

                            you can't SET the contents of a calculated field but, if you have FM 9 ( at least ) , you can apply to that field a 'conditiona formatting' based on a calc to change the fill and/or the text color.

                             

                            Which version of FM do you have ?


                            • 11. Re: Conditional formatting for button click
                              CarrieB.
                                

                              Okay, so I was messing around with some of the new templates in FileMaker Pro 10 (which I use), and noticed in the Contact Management file there are fields and scripts that essentially do what I am trying to do. When you go to list view, you can choose to sort by Company, Name, Email, etc. And, when you choose which sort you would like, it changes the image. They do this with global, container and calculated fields. So, I made a container field with a checkmark image, then I made a container field with a blank image (I know this is not the way I am suppose to do it! =), Then I added the calculated field next to my button, so that it can change from blank to the checkmark depending on the buttons pressed. I can get the checkmark to appear no problem, but I'm still trying to figure out how to make it go away when another button is pressed without making my script terribly long. I am really new at this, so if you can give any advice, you may want to really spell it out for me. =)

                               

                              Thank you so much!

                              • 12. Re: Conditional formatting for button click
                                raybaudi
                                  

                                Ok, back to topic.

                                 

                                Create a new file ( Test ) with only 3 fields:

                                 

                                A ( with the option to auto-enter a serial number starting from 1 step 1 )
                                B ( with the option to auto-enter as data: 1 )
                                C = calculated field with calc: A*B

                                 

                                In Layout Mode:

                                 

                                1) delete field A and field B
                                2) select the field C
                                3) from menu: Format >> Conditional... >> Add >> Condition >> Formula is : not Mod ( Self ; 2 )
                                4) check 'Bold' and choose yellow as the 'Fill Color'

                                 

                                In Browse Mode View as Table...

                                 

                                Now, every other time you add a new record, the Fill of the calculated field will be yellow and the text bold.

                                 

                                This demostates that a calculated field CAN be formatted based on a calculation.


                                • 13. Re: Conditional formatting for button click
                                  CarrieB.
                                     Finally fixed it via a calculated field (container with either a checkmark or no checkmark). This seems to work a bit better for me. Thanks!!
                                  • 14. Re: Conditional formatting for button click
                                    LeoB

                                    I wandered through conditional formatting for half an hour trying to figure out how to do this.

                                     

                                    This solution works perfectly!

                                     

                                    Thanks