You’ve added your email button next to the email field, but what if that field is empty? There wouldn’t be much point in clicking the button since the email couldn't be sent. In that case, let’s hide the button so that the user isn’t distracted by something they can't use.
You’ll use the “Hide object when” condition to cause the button to disappear when there is no email address in the field. You used this feature in the Learn phase to make a “Click here to sign” message disappear.
The “Hide object when” condition can be applied to any layout object in Browse and Find mode. When the condition evalues to “true”, the layout object is not displayed.
In the case of your button, you’ll not only cause it to disappear when the email field is empty but also when the window is in Find mode, since in that case as well there is no email address for the button to use.
This is a good technique to remember: if a functional button doesn’t work properly in Find mode, you might as well make it disappear. This simplifies the interface and gives a visual cue that the user has changed modes.
Here’s how the result looks in the example solution:
- In Browse mode, with the Work Email field populated and the Personal Email field empty:
- In Browse mode, with the Work Email field empty and the Personal Email field populated:
- In Find mode (note the magnifying glass icons in each field):
To hide the email button when the email field is empty or the window is in Find mode.
- Select your email button.
- Use the Inspector > Data tab > Behavior area to set the Hide object when condition to this:
IsEmpty( [your email field] ) or Get(WindowMode)=1
The example solution has this expression:
IsEmpty( Contacts::Work Email ) or Get(WindowMode)=1
The first part of the expression tests whether your field is empty. The second part checks whether the window is in Find mode.
- Use the Inspector > Data tab > Behavior area to select the Apply in Find mode checkbox.
Unless this checkbox is selected, your Hide object when condition will only be applied in Browse mode.
- Test the results in Browse mode by populating your email field (the button should appear) and clearing it (the button should disappear).
- Test the result by entering Find mode and seeing whether the button disappears.
- If you have more than one email button, repeat steps 1 to 5 for each one, making sure that you reference the appropriate email field in each case.