10 Replies Latest reply on Dec 12, 2012 10:28 AM by KatG

    Change button color after it has been triggered?

    KatG

      Title

      Change button color after it has been triggered?

      Post

           I have a script button that names and dates a report and saves a .pdf to a folder.  The script returns to that layout, is there anyway to format the button to change color after this has been done?  My mouse isn't the best and sometimes I don't know if I have effectively clicked on the button. 

        • 1. Re: Change button color after it has been triggered?
          philmodjunk

               And when, if ever, would you want that button to revert back to its original color?

               If you only want the color change to be for the current "session" (change will not persist after you close the file), you can use a global variable. In other cases, you may want ot use a field --either global or local depending on what you need to keep track of the button's status.

               Using a global variable for this example named $$Clicked....

               Use this as your conditional format expression:

               $$Clicked

               and specify the fill color that you want when the button is clicked.

               Have the button's script start with this script step:

               Set Field [$$Clicked ; value: True ]

               If you need this color change to persist, you will need to use a field in place of the variable.

          • 2. Re: Change button color after it has been triggered?
            KatG

                 yes color change for the current session, just to let me know the mouse worked or the tap was firm enough.

                 So I created a text  field (on the table the report is based on) and named it     $$Clicked   and clicked global storage.

                                                            (what is the significance of 2 dollar signs?)

                 Should th condititonal format be  "  Value = $$Clicked "   or "  Formula is $$Clicked "    (without the quotes)

                 I duplicated the script and am now trying to add the step I'm getting an error message. What am I missing?

            • 3. Re: Change button color after it has been triggered?
              philmodjunk

                   There's a typo in my last post. that script step should be:

                   Set Variable [$$Clicked ; value: True ]

              • 4. Re: Change button color after it has been triggered?
                KatG

                     I'm still getting the error message  "something is expected...."

                • 5. Re: Change button color after it has been triggered?
                  philmodjunk

                       When you specify the details for set Variable, you get a dialog box. Enter $$Clicked in the upper box. Enter: True in the middle box and leave the bottom one empty.

                       When you click OK, you should then see:

                       Set Variable [$$Clicked ; value: True ]

                       The semi colon and "Value:" will appear automatically--don't try to type them in.

                  • 6. Re: Change button color after it has been triggered?
                    KatG

                         Whew. Almost there. There seems to be an issue of what my understanding of a current session was. Oops.  I thought it meant when I left that layout and went back to the original layout and subsequently generate another report.... when I do this the box is stiill red. When you wrote "close the file" did you mean the Database itself? If so, I will need more help.

                         This database is for me to document progress notes for my patients.  I don't know if it matters but I switched over to anchor bouy format some time ago on the advice of another forum developer (and though it has been a great deal of work,  I am glad I did...)   I have a layout where I enter the majority of the data and from there a report which is the progress note... the end result appears as a word document.  The report has a button which returns me to the main layout after I generate the report. So I will be going back and forth between the two layouts.

                         If I think I clicked the button without an obvious cue (the color change) and I in fact did not, I will not realize that report was not generated, unless I have the button take me out of FM and go to the .pdf folder on the computer and look for the report on the spot. (I am just trying to save steps).  As it stands I check the folder each time to make sure the .pdf is there and that is actually how this problem presented, ... there were reports missing. and It was too light a touch on the mouse.... whatever.

                         To make a long story longer :) Such is the method to my madness.  Is there some step we can add to the script that will uncolor the box upon exit of the layout or something like that? 

                    • 7. Re: Change button color after it has been triggered?
                      philmodjunk

                           Yes, I meant when you close the database file. Changing layouts does not close the file. Global variable retain a value until the file is closed.

                           Your scripts that change layouts, however, can also clear the value in this field when you use scripts to change layouts.

                           Script triggers, such as OnLayoutExit, can also perform a script that clears this field--but be careful of any scripts that leave the layout to do some "housekeeping" (such as creating a record in a related table) and then return as they will trip this same trigger unless you use another global variable to selectively disable the script trigger's script.

                      • 8. Re: Change button color after it has been triggered?
                        KatG

                             So to simply clear the field, should I add a step to the return button script that is the opposite of the other one?

                             Set Variable [$$Clicked ; value: False ]   

                             Or would it be "cleaner" or "safer" to add the step to the script on the first layout that takes me to the report...to avoid the pitfalls.... have that script "clear the deck" on enter? I'm sure there are many ways to approach this but for those of us "nondevelopers", we tend to be very literal in this process.

                              

                        • 9. Re: Change button color after it has been triggered?
                          philmodjunk

                               Either works. I don't know enough about your database to say which is "safer". Note that I have no idea what your "return" button does nor why you have one on your layout.

                               Simplest is probably to use the OnLayoutExit script trigger to perform this script. You can write it this way if there are scripts performed from this layout that change layouts where you don't want the variable modified when they are performed:

                               If [ Not $$TriggersOff ]
                                 Set Variable [$$Clicked ; value: False ]
                               End If

                               Then any script that shouldn't trip this script trigger, you can add:

                               Set Variable [$$TriggersOff ; value: True ]

                               #Put the rest of your script here

                               Set Variable [$$TriggersOff ; value: False ]

                               To keep that script from accidentally changing the value of $$Clicked. But keep in mind that you only need to do this if you have a specific type of script being performed from your layout.

                          • 10. Re: Change button color after it has been triggered?
                            KatG

                                 I reviewed the script and there does not seem to be an issue as you have suggested, but thanks for pointing out the potential pifalls ....

                                 I added      Set Variable [$$Clicked ; value: False ]    to the return script ( which is simply a "go to layout script")    that takes me back to the main layout and then when I generayed another report  and went back to the report layout, the color was cleared.

                                 Mission Acomplished!

                                 Thanks! Thanks and more Thanks!