9 Replies Latest reply on Apr 27, 2017 9:24 AM by everyman

    TriggerTargetPanel and TriggerCurrentPanel - problem

    gfsymon

      Hi,

       

      I'm running 14.0.6 Advanced.

       

      I have an old file which uses tabbed panels.  I have used the OnObjectModify in the past, to script trigger and set a variable for the panel name.  This worked fine.  I have changed the panel names and after much bug hunting trying to understand why my scripts no longer work, it seems that OnObjectModify isn't working either ... although it still does on another layout.

       

      So I'm trying the TriggerTargetPanel and TriggerCurrentPanel via OnPanelSwitch in script triggers and a strange thing is happening.

       

      On my old file, they are returning the values, tab number + name (viewed via Data Viewer) but they are not the correct tab names!!  These are old names which have been changed.  Changing them again (and clicking 'confirm') doesn't update them for the functions ... but, they do update in Browse and Layout modes.  So they look fine on the layout, but the values are incorrect.

       

      So I did a file recovery.  Still the same.

       

      So I made a new file with only a tab.  I run the exact same script trigger and ... huh?  It doesn't return the tab names at all!  Only the tab numbers (1 and 2).

       

      So my question is obviously, why not and also, is there another *reliable* way of getting the current panel name for use in scripts?

       

      I'm attaching 2 files.  One ... my old file, cleaned out of all but the offending tab and my new test file.  Obviously you'll need FM Advanced to see what's going on in the Data Viewer.

       

      Any help much appreciated.

        • 1. Re: TriggerTargetPanel and TriggerCurrentPanel - problem
          everyman

          The Get ( ) functions for tab panels don't return the text on the tabs.  They return the *object name* of the panel.

           

          If you look at the Inspector (in Layout mode), you'll see that the tabs in your first file all have names (which are returned by the Get ( TriggerTargetPanel ) and Get ( TriggerCurrentPanel ) calls).  The tabs (as objects) in the second file have no names and therefore no name is returned.

          • 2. Re: TriggerTargetPanel and TriggerCurrentPanel - problem
            gfsymon

            Thanks Everyman.

             

            I can't tell how much I've been going round in circles on this.

             

            It seems like an easy trap to fall into though.  The names of the tabs are not the same, between the tab and the Inspector.

             

            Of the various methods of using tab names/object names in scripts, when moving between tabs, which would you recommend?

            • 3. Re: TriggerTargetPanel and TriggerCurrentPanel - problem
              philmodjunk

              You have to use object names. The labels on the tabs cannot be used for this purpose. The same applies to buttons. The text used to label a button cannot be specified, but an object name assigned to it can be.

              • 4. Re: TriggerTargetPanel and TriggerCurrentPanel - problem
                gfsymon

                Thanks Phil.

                 

                I've gone back to OnObjectmodify which is working now that you've reminded me that it is the Object Name and not the Tab Name that it requires.  All working again. 

                 

                FWIW, I couldn't get TriggerTargetPanel or TriggerCurrentPanel to work at all.  The values were being set in the variable, but the subsequent script, which uses the variable, wasn't recognising it.  It just skipped right past.  Very confusing.

                • 5. Re: TriggerTargetPanel and TriggerCurrentPanel - problem
                  everyman

                  Of the various methods of using tab names/object names in scripts, when moving between tabs, which would you recommend?

                  My own preference is to write the scripts as generically as possible: never put object names directly into scripts, always pass object names as script parameters, etc.  This will avoid brittle code, provide hooks for new features, and help you build a library of scripts you can use without modification in other projects.

                   

                  Whether I use triggers attached to objects or buttons on the layout  depends on the specific project, user expectations about behavior, and more.  The underlying "Move to Object <parameter>" script can be used in all cases.  Button actions and triggers can access it directly, or (depending on the need) use wrapper scripts to perform additional actions.  (Remember to pass through required parameters to scripts called from the wrapper.)

                  • 6. Re: TriggerTargetPanel and TriggerCurrentPanel - problem
                    philmodjunk

                    Those functions should be used in combination with the OnPanelSwitch trigger. If you check the documentation on them in help, you find that they return a list of two values. One value is the number of the panel and the other value is the object name--if any object name was assigned to the panel. So you usually have to use getValue to parse the desired value from the result of these functions.

                    • 7. Re: TriggerTargetPanel and TriggerCurrentPanel - problem
                      everyman

                      philmodjunk wrote:

                       

                      Those functions should be used in combination with the OnPanelSwitch trigger. If you check the documentation on them in help, you find that they return a list of two values. One value is the number of the panel and the other value is the object name--if any object name was assigned to the panel. So you usually have to use getValue to parse the desired value from the result of these functions.

                      One reason I prefer to use object names, instead of object numbers, is that once they're set there's little reason (if any) to ever change them.  Panel numbers are "brittle" and will change when:

                      1. a new tab or panel is added
                      2. tabs/panels are re-arranged
                      • 8. Re: TriggerTargetPanel and TriggerCurrentPanel - problem
                        philmodjunk

                        In my book object names are also pretty brittle. It's pretty easy to alter an object name and not even notice that you've changed it.

                         

                        On the other hand, a descriptive object name is much less cryptic than a simple index number so I prefer object names over the numbers for that reason.

                        • 9. Re: TriggerTargetPanel and TriggerCurrentPanel - problem
                          everyman

                          philmodjunk wrote:

                           

                          In my book object names are also pretty brittle. It's pretty easy to alter an object name and not even notice that you've changed it.

                          True.  It's happened to me (and most likely almost everyone else).  Moving rather far afield from the original post: I often place a text object in the "offscreen" area of a layout to document things that can appear at first glance to be extraneous.  This includes object names, objects that trigger a script, and more.

                           

                          Your point about using descriptive names is also well-taken.  (A UUID might be unique, but that doesn't make it appropriate for every I-need-a-unique-identifier situation.)