Friday, October 26, 2012

Same Time, Same Place, Different Buttons

An elegant solution to an unexpected dilemma (FileMaker Pro 12):

I have two layouts. Let's call them Projects and People.* Here's what the table relationships look like:

Projects <------- Join Table -----> People

Sometimes, when looking at a project, I just want to get more information on the people related to it. So I set up a "Related Record" button that takes me to People, and another button/script combo that takes me back when I'm done. I call this button the "Back" button. Pretty crazy, no?

But sometimes I want to add a person to the Project. I have a script that does all the right calculations, grabs all the right info, plops the user down on the People layout and lets them enter data. Then the user must click a button ("Done") to show that they are done entering data. This button Resumes the script, which creates the necessary join record and takes the user back to the Project layout. So far, so good.

But it looks tacky to have a "Back" button and "Done" button on the same layout. I could create otherwise duplicate layouts that have distinct buttons, but that's a lot of pain to maintain/create. I want to use the same layout, but have different buttons depending on what the user's doing.

I could alternatively merge the scripts together—and I did briefly play with this—but it turned out to be complicated and I'm under a deadline.

So I searched around and found this.

Aha! Not a complete solution, but inspiration struck. And hard.

I created a tab object with two tabs, called "Back" and "Done". On each tab area I placed one of the buttons. I gave the tabs names ("Back" and "Done", naturally). Then I made the entire tab object "invisible" (i.e. formatted its text, lines, background, etc., to the same color as the layout's background). Finally, I made the "Back" tab default, and inserted a "Go to object 'Done'" step into my script. Voila'! It works!

Now if the user wants to look at or edit info, s/he will go to the layout and see a "Back" button. And they can indeed go back when they are ready. But of they want to add a new user, they go to the layout, the script pulls up the "Done" button on the "Done" tab, and when they are "Done" they return to the Project layout. All the magic happens in the background.

I did add one more feature. I didn't like seeing a black rectangle appear around the invisible tab (a result of the "Go to Object" command), so I made a rectangle of the same color as the background and placed it over the top of the tabs. No more black rectangle! This has the added advantage that now the user can't accidentally click on the tabs and pull up the wrong button. Booyah!

-----------------------------------------------------------------

* because that's what they're called.

No comments:

Post a Comment