10 Replies Latest reply on Sep 6, 2014 2:31 AM by Paul Richardson

    OnObjectKeystroke Problem

    Paul Richardson

      In Filemaker 13 I have a portal with an OnObjectKeystroke trigger assigned. I'm looking for arrow up and arrow down to reorder portal items.

       

      The condition IF Code ( Get ( TriggerKeystroke ) ) = 29 // up arrow

       

      works fine, but what I actually want is to trap option-up

       

      With the condition IF Code ( Get ( TriggerKeystroke ) ) = 29 and Get (TriggerModifierKeys) = 8 // option-up arrow

       

      the script fires twice! This was not the case in Filemaker 12, I'm sure.

       

      (In fact even with the condition IF Code ( Get ( TriggerKeystroke ) ) = 29 the script fires twice if a modifier key is held included.)

       

      I'll be very grateful for any tips on how to combine keystroke and modifier as a single event in Filemaker 13.

        • 1. Re: OnObjectKeystroke Problem
          keywords

          Have you tried using OnObjecyModify instead?

          • 2. Re: OnObjectKeystroke Problem
            Extensitech

            Trying this in Windows, I can't get onObjectKeystroke to fire at all with the Alt or Ctrl keys down. I can with shift, though. Have you tried a different modifier key?

             

            Chris Cain

            • 3. Re: OnObjectKeystroke Problem
              Paul Richardson

              OnObjecyModify doesn't help - The user is not making a modification which could trigger. The modifications are made by the script and there are three involved.

               

              OnObjectKeystroke is (should be)  much more elegant.

              • 4. Re: OnObjectKeystroke Problem
                Paul Richardson

                On a Mac shift, option and control all (mis)behave.

                • 5. Re: OnObjectKeystroke Problem
                  AlanStirling

                  Hi Paul

                   

                  Perhaps you don't need to use two 'Trigger' functions?

                   

                  If you are getting two script triggers and only require one, then what about replacing the 'Get ( TriggerModifierKeys ) = 8' with 'Get ( ActiveModifierKeys ) = 8'?

                   

                  I haven't tried this, but it would be the next step that I would take ...

                   

                  Best wishes - Alan Stirling, London UK.

                  • 6. Re: OnObjectKeystroke Problem
                    Paul Richardson

                    Hi Alan,

                     

                    unfortunately that doesn't work. FileMaker is still seeing two independent keystrokes and triggering the script twice.

                     

                    Paul

                    • 7. Re: OnObjectKeystroke Problem
                      ch0c0halic

                      I see this as a man-machine interface problem. That is because these are two separate keystrokes. But, it sounds like you're testing them as if they were simultaneous.

                       

                      Use the ScriptTrigger OnObjectKeystroke, but have the script pause .5-1 sec. (or longer as hunt-and-peck typists take more time to locate the keys) before checking for the keys being down. This time lag allows for human reaction times.

                      • 8. Re: OnObjectKeystroke Problem
                        BruceHerbach

                        Hi,

                         

                        I played with this a bit.  Attached is the file.  In this version,  it navigates to the next or previous record depending on which arrow key (up or down ) is pressed.  You must click on portal row.  I used global variables to catch the keys pressed and count the number of times the script runs.  If I ran it with the debugger opened it affected the result.  So you can watch what is going on in the data viewer.

                         

                        On my MacBook Pro I found the following:

                        • Holding the control key the script worked correctly
                        • Holding the alt (option) key the script ran twice
                        • Holding the command key prevented the script from running at all.  This may be a result of an apple add on I have that shows keyboard shortcuts when the command key is held for an extended time.
                        • With no extra keys being held,  it reported that option key 48 was being held down.  This was the same using both Get ( TriggerModifierKeys) and Get(ActiveModifierKeys).

                         

                        Anyway this sounds like a bug.  I'm running FileMaker Pro Advanced 13.0v3 on OS X 10.8.5 on a Retina, Mid 2012 MacBook Pro.

                         

                        HTH

                        • 9. Re: OnObjectKeystroke Problem
                          keywords

                          An interesting test file Bruce. I tested it on a MacAir running FM13 and OSX 10.9.4 and can add to your results as follows:

                           

                          •     control + up and down arrows are both keyboard shortcuts used to toggle between Mission Control and Application windows, so the script does not fire at all. These shortcuts can be switched off, however—script then works correctly as per your test

                          •     option key appears to cause script to run twice, as it jumps two portal rows. However, when run with debugger on it only runs once and moves one portal row

                          command key prevents script running as you found, so it is not an Apple add-on. I couldn't find any way to switch this off, so maybe it's a reserved key or something of the sort

                           

                          We all live and learn.

                          • 10. Re: OnObjectKeystroke Problem
                            Paul Richardson

                            Thanks, Bruce, for your test file.

                             

                            Just a note - FileMaker Help states: Get(TriggerModifierKeys) -> Notes -> Mac OS: Command key combinations do not activate script triggers.

                             

                            In FM12 my script, and your test file, exhibits another behaviour. The script when triggered on the first portal row loops throught the entire portal, as though Go to Portal Row[] is triggering. Maybe this is well known.

                             

                            I had said I was quite sure that my script worked as expected in FM 12. It must have been FM11 though. Unfortunately I can't test that.

                             

                            As you say, eveything seems to point to this being a bug.