10 Replies Latest reply on Jun 11, 2017 11:23 AM by makerbert

    OnObjectEnter script trigger for Popover Button

    tcmeyers

      Title

      OnObjectEnter script trigger for Popover Button

      Post

      The FileMaker Pro 14 Help states that for the OnObjectEnter script trigger:

      • Clicking a button, a popover button, or a panel control does not activate this trigger on the button or tab. Pressing Tab to navigate to a button or tab and make it the active object does activate this trigger.

      Focusing on the Popover Button, I don't understand the reasoning for not having the OnObjectEnter script fire when you activate the Popover. If someone knows, please tell me. For me, I would like to have it fire so that a script can set things up supporting the contents of the Popover.  Since it's not a regular button, there isn't a script that you can select just because it was clicked. I had thought OnObjectEnter would do it, but no.

      The workaround that I did is to make a regular button an put it over the Popover button, and have it do the setup steps and do a Go To Object [ Object name: "the popover name" ] to get the popover to open. This works but it seems kludgy.

      Troy

        • 1. Re: OnObjectEnter script trigger for Popover Button
          philmodjunk

          That info is a bit ambiguous.

          Here's how to use OnObjectEnter with a popover button:

          Use the Popover Panel, not the popover Button. Right click it and you'll find that you can specify the OnObjectEnter trigger and it will trip when you click the popover button.

          It works this way because OnObjectEnter is tripped when an object get's the focus. While it may seem a bit strange, buttons do not get the focus when they are clicked. The popover's panel, on the other hand, gets the focus when the popover button is clicked to open it.

          (Buttons do not get the focus when clicked so that you can use buttons to perform scripts that work with the contents of a field that has the focus. If clicking a button gave it the focus, there would be no way for the script to determine what field or what selected text within that field had the focus at the time the button was clicked.)

          • 2. Re: OnObjectEnter script trigger for Popover Button
            tcmeyers

            Thanks, Phil !

            Makes sense, and works.

            As an aside, we've been able to turn non-button objects into buttons, for example a field or static display text. I don't see a way to turn these things into popover buttons. Am I missing that? Or should I put this in as a feature request? For now I've been making transparent popover buttons and putting them over the other object.

            Troy

            • 3. Re: OnObjectEnter script trigger for Popover Button
              philmodjunk

              Popover buttons aren't really buttons. They are more accurately described as a special kind of tab control.

              There are two ways that a mouse click on such a layout object can be used to open a Popover. you have discovered one of the two.

              The other method is to use button setup to turn the object into a conventional button that performs a single Go to Object or go to field script step. You use one of these to put the focus on either the popover panel or an object/field inside the popover panel. So you can select the popover panel and use the Inspector's Name box to give it a name or you can give an object inside the panel an object name or just use go to field to put the cursor into a field inside the popover panel.

              These same tricks also work for tab and slide control panels. In each case, putting the focus on the panel or an object inside of it makes that panel visible.

              • 4. Re: OnObjectEnter script trigger for Popover Button
                BruceRobertson

                Use a buttonbar; with two buttons defined. The first button is a standard button. The second button is the popover button. Set the popover button to always hide. Design the script attached to the first button so that it goes to an object on the popover panel or goes to the popover panel itself.

                • 5. Re: OnObjectEnter script trigger for Popover Button
                  philmodjunk

                  Which is essentially the same method I just described, but implemented in a way that can only be done with FileMaker 14. That certainly doesn't make it a bad way to go. What advantage do you get by using the button bar?

                  • 6. Re: OnObjectEnter script trigger for Popover Button
                    BruceRobertson

                    I think they are both useful methods but they are quite different. Each can be understood and used where the developer prefers.

                    For instance, in another forum (fmforums.com) there was a request to have a new record created when navigating to the popup. If your suggested technique was used to solve this particular problem, then on enter is triggered twice. The first trigger fires the script as you have suggested. If it creates a new record then the script fires again because you have "entered" the new record. The script has to have logic which prevents an endless chain of new records from being created.

                    If you use the buttonbar method, then you can trigger a script which will take actions BEFORE entering the popup (such as create new record) or you can nav to a different popup, etc. Plus by using the buttonbar you have a single layout object which you can move and place where you want. 

                    Sometimes it can be helfpul to NOT have the script button and popup button attached to each other. You may place the script-containing button in one location on a layout; and have the actual popup in a different location. This can be handy, for instance, if you want to have the popup contain a portal but you want the triggering button to, itself, be in a portal row. If we could attach FileMaker files here I would attach an example. There is an example available at FMForums. When the forum merge takes place, it will be possible to attach examples to posts.

                    • 7. Re: OnObjectEnter script trigger for Popover Button
                      philmodjunk

                      I think you need to read my comments again. I think that you missed the post where I described using Go to object  to open the popover--exactly what you recommended, just not from a button bar. But note that this method does not require using a button bar--a feature only available in FMP 14. So I asked what advantage, if any existed to putting both buttons inside a button bar.

                      Yes, a button bar lets you move them as a single object, but you can also select the two buttons and group them and then you have achieved that same convenience without using a feature specific to FileMaker 14--which might not yet be something all people reading this thread will be able to use. So you describe an excellent way to do this, but only if you are using FileMaker 14.

                      I only used a script trigger to answer the original question which was how to have a script run when a normal popover button is clicked and OnObjectEnter does that nicely.

                      • 8. Re: OnObjectEnter script trigger for Popover Button
                        macwombat

                        Thanks - thought I was going crazy because it wouldn't work on the popover button.

                        • 9. Re: OnObjectEnter script trigger for Popover Button
                          user375

                          Follow-up for version 15: a Popover can be configured with an OnObjectEnter script to go directly to an object or field. You have to set this on the Popover object itself, not the button that called it. This might be a little easier way of doing this going forward.

                          1 of 1 people found this helpful
                          • 10. Re: OnObjectEnter script trigger for Popover Button
                            makerbert

                            philmodjunk

                            thanks mate! If you ever visit the Netherlands, there is a cold beer waiting for you! :-)