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.
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 )
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:
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
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.
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.
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?
With zero width tabs, the user cannot click on the tab by accident.
And the file also shows another method for hiding buttons.
Why you do not try? I've done. It is possible
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.
The method illustrated by MetaSys is one of the methods in the demo file that I shared.
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.
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.
I agree that it works, (Said that in my last post), just not totally thrilled with the change in mouse down appearance required...
Retrieving data ...