12 Replies Latest reply on Jul 26, 2013 9:03 AM by philmodjunk

    Conditional Formating



      Conditional Formating


           I would like to set conditional formatting on a rectangle to hide a button. When the value of a field is not a whole number (no decimals) then show the rectangle to hide the button.  Not sure of the calculation.

        • 1. Re: Conditional Formating

               Hi John,

               You won't be able to use a rectangle - you can't apply conditional formatting to a rectangle but you can use a text block or a button (just specify 'do nothing' ) or possibly just apply this to the button itself.  Anyway, if you want it to hide the button if it is NOT a whole number, i.e. there is a remainder (decimals), try this:  

               Set the button or text block to transparent and then formula = 

               Mod ( yourField ; 1 )

               ... this returns a number if it contains decimal which translates to boolean true (1) so then below set the fill color to hide the underlying object.  If you want the opposite, it would just be:

               not Mod ( yourField ; 1 )

          • 2. Re: Conditional Formating

                 Unfortunately, the button is still active even if it is hidden by a text block; that is, if anyone click in the area of the button, the associated action is activated.

                 So, if you want to be sure that there is not any possibility to activate the button, you can:

            1.           duplicate the layout, one with the button and the other without
            3.           use a global variable or a global field and, testing his value, exit immediately from the button script, doing nothing. Moreover you can use conditional formatting to the button, displaying it as “not active”
            • 3. Re: Conditional Formating

                   You can also place the button inside an invisible tab control this both hides the button and shields it from mouse clicks. It is one of the visibility control tricks demonstrated in this file: https://www.dropbox.com/s/8levaz6deiyzjr8/LayoutObjectVisibilityControlDemo.fp7

              • 4. Re: Conditional Formating

                     Keep in mind that in version 12, mouse clicks can be hidden completely.

                     You simply set the Inspector > Appearance > Styles pop-up which says 'normal state' ... and set the 'Pressed' (as well as In Focus and Hover) to transparent.

                • 5. Re: Conditional Formating

                       As for stopping the action ... once you remove the click flash from the button, your script should just test and only act if it should ... it is very simple to set up.  I would not use hidden tabs nor would I create duplicate layouts since it adds unnecessary complexity.

                  • 6. Re: Conditional Formating

                         I know these tricks PhilModJunk, but again if the user click inadvertently in the tab area, the hidden part became visible.

                         So, why add this complexity when you can solve it with a simple test to control the script?

                    • 7. Re: Conditional Formating

                           With zero width tabs, the user cannot click on the tab by accident.

                           And the file also shows another method for hiding buttons.

                      • 8. Re: Conditional Formating

                             Why you do not try? I've done. It is possible

                        • 9. Re: Conditional Formating

                               Let us assume your FM database has 'Transaction' table with primarykey and Amount fields. The requirement is, when the'amount' field has value which is whole number, then show a button and in case the value of 'Amount' field is not whole number hide the button on layout. For this, let us follow these steps
                               1. In 'transaction' table, create number field ' WholeNumberFlag', with auto-enter calc Mod ( Amount; 1)
                               2. Create table 'DisplayButton', with one field 'ConstantZero'. Add only one record to this table and set value '0' (zero) in 'ConstantZero' field.
                               3. Set relationship between 'Transaction' and 'Displaybutton' table, with fields "Transaction:WholeNumberFlag' and 'DisplayButton:ConstantZero'
                               4. Now on layout, which is based on 'Transaction' table, add portal of 'DisplayButton' with only one row. In this portal, don't include field, just place your button. Set the portal attributes, so that it is not displayed/visible - hide borders, settit transparent.
                               5. here you go. When Amount field value is wholenumber, relationship is set and button is displayed.

                          • 10. Re: Conditional Formating

                                 The method illustrated by MetaSys is one of the methods in the demo file that I shared.

                            @Gianandrea Gattinoni

                                 Various of us have been listing different options. They each have pros and cons and its up to our OP to read them over and decide on which option they like most.

                            The methods you and LaRetta have described can work quite well, but they change the appearance behavior of this button in a way that makes it different from other buttons in the system. (Hand no longer appears over it, button no longer visibly responds to mouse click...) That may be acceptable and if so that's definitely the way to go, but what I and others have suggested allows you to have a button that appears and disappears without needing to either a) you have a mystery zone on your layout where the hand appears and which highlights when clicked or b) a button that when visible fails to show the hand cursor and does not highlight when clicked. (and b may only be used with FMP 12 or later.)

                                 PS. I must admit that with FMP 12 I am tending not to enable the hand option on all my buttons, using other "hover" settings instead to show that a layout element is a button that can be clicked.

                            • 11. Re: Conditional Formating

                                   Phil said, " (Hand no longer appears over it, button no longer visibly responds to mouse click...)"

                              Well, what I suggested works VERY WELL, Phil - have you tried it?  I've used it since 12 came out and it is liked by Users.  And no, in 12 we are finally able to ditch the dorky hand.  I NEVER use the hand any more. 

                                   One must also weigh the cost of replication, resources and upkeep on the various techniques suggested.  Oh, and "(and b may only be used with FMP 12 or later.)"  Oh Phil, 12 can only be used with 12 (or later) anyway so suggesting that the technique would not be backward-compatible is a bit off. ;-/

                                   BTW, the 'OP' has a name ... John.   

                              • 12. Re: Conditional Formating

                                     I agree that it works, (Said that in my last post),  just not totally thrilled with the change in mouse down appearance required...