14 Replies Latest reply on Sep 17, 2013 11:13 AM by CekariYH

    Ctrl-Tab, Ctrl-Enter and Ctrl-NumpadEnter

    CekariYH

      Title

      Ctrl-Tab, Ctrl-Enter and Ctrl-NumpadEnter

      Post

           How do I trigger these in code?

            

           /Cekari

        • 1. Re: Ctrl-Tab, Ctrl-Enter and Ctrl-NumpadEnter
          rvarghes

               The first one you hold down the Ctrl key and press the Tab key, similar for the others.  Does this answer your question?

                

          • 2. Re: Ctrl-Tab, Ctrl-Enter and Ctrl-NumpadEnter
            philmodjunk

                 There are two get functions that you can use to identify which modifer keys are down at the time that the script step executes:

                 Get ( TriggerModifierKeys )

                 Get ( ActiveModifierKeys )

                 Looking up the Get function in FileMaker help can show you a lot of functions that are very useful in FileMaker.

                 And note that ctrl-enter (Qwerty section) is the same key as pressing the numeric keypad Enter.

            • 3. Re: Ctrl-Tab, Ctrl-Enter and Ctrl-NumpadEnter
              CekariYH

                   @ Robin: hahaha nice one,  I should have added in code... ;-)

                   @ Phil: Yes, I know those two, but I can't make it work as I don't know how to get the combinations of the 3 pairs.

                   Ah... perhaps I should use an Alt- combo instead then...

                   I have some big multi-line text-fields setup but need the Tab, Enter and NumPadEnter as normal editing keys, no problem there, just uncheck the "go to next field" for all 3, but then need a way to exit the fields with key presses and not the mouse so I though those combos would work nice.

              • 4. Re: Ctrl-Tab, Ctrl-Enter and Ctrl-NumpadEnter
                philmodjunk

                     OnObjectKeystroke is the scrip trigger to use and then Get ( TriggerKeystroke ) will return the key that is pressed (and you can use it with the code function to get the code for special keys like these and Get ( TriggerModiferKeys ) will return a numeric key that is unique for the specific combination of modifier keys that were down at the instance the script trigger was tripped. You have to check both function results to determine the combination of key plus modifiers that tripped your script trigger.

                • 5. Re: Ctrl-Tab, Ctrl-Enter and Ctrl-NumpadEnter
                  CekariYH

                  Get ( TriggerModiferKeys ) didn't give any value for any Ctrl-"combo" but Alt-"combo" did.</didn'tk,>

                       So, Alt-Tab and Alt-Enter gave a value of 8 and then Shift-Tab a value of 1, so now it works for the text fields.

                       If [Get ( TriggerModiferKeys )] = 8

                         Go To Next Field

                         Exit Script [0]

                       Else If [Get ( TriggerModiferKeys )] = 1

                         Go to previous Field

                         Exit Script [0]

                       End If

                       Hope I din't missed something that might do something unexpected with this simple approach on a text-field :-)

                        

                       Thanks again Phil.

                        

                  • 6. Re: Ctrl-Tab, Ctrl-Enter and Ctrl-NumpadEnter
                    philmodjunk

                         Hmmm, the get function in English is actually: Get ( ActiveModifierKeys). My mistake.

                         I don't recognize what you mean by "ctrl-"combo".

                         Many modifier key-regular key combinations can't trip the script trigger as the OS or FIleMaker pre-empts them for something else and the trigger is never tripped in those cases. Ctrl-V for pasting from the keyboard, for example would be a case where the key stroke never trips the trigger.

                         Your script only checks to see if a particular modifier key is down. It does not check to see what regular key was down at the same time. Since you want to go to the previous field when the modifierkey result is 1, any attempt to input data while the shift key is down--such as inputting a capitalized word, should cause your script to go to the previous field. I doubt that this is what you want here.wink

                    • 7. Re: Ctrl-Tab, Ctrl-Enter and Ctrl-NumpadEnter
                      CekariYH

                            

                           

                                Hmmm, the get function in English is actually: Get ( ActiveModifierKeys). My mistake.

                           And I just copied what you wrote, but know the one in Swedish anyway :-)

                            

                           

                                I don't recognize what you mean by "ctrl-"combo".

                           I mean Ctrl- in combination with Tab/Enter/NumPadEnter ;-)

                            

                           

                                Many modifier key-regular key combinations can't trip the script trigger as the OS or FIleMaker pre-empts them for something else and the trigger is never tripped in those cases. Ctrl-V for pasting from the keyboard, for example would be a case where the key stroke never trips the trigger.

                           Ah... wish there was a list of what different non-regular key-combination has for value somewhere... 

                            

                           

                                Your script only checks to see if a particular modifier key is down. It does not check to see what regular key was down at the same time. Since you want to go to the previous field when the modifierkey result is 1, any attempt to input data while the shift key is down--such as inputting a capitalized word, should cause your script to go to the previous field. I doubt that this is what you want here.wink

                           LOL big surprise, no capital letters there... so I need to find some other key-combo for that one surprise

                      • 8. Re: Ctrl-Tab, Ctrl-Enter and Ctrl-NumpadEnter
                        philmodjunk

                             As far as I know, you can't use the number keypad Enter key to edit data in your text field. I'd leave it set to move you to the next field in the tab order.

                        • 9. Re: Ctrl-Tab, Ctrl-Enter and Ctrl-NumpadEnter
                          CekariYH

                               True, so I leave it as is.

                          • 10. Re: Ctrl-Tab, Ctrl-Enter and Ctrl-NumpadEnter
                            CekariYH

                                 Ok, seems I need to use Get(ActiveModifierKeys) after a Get(TriggerModifierKeys) has triggered the script?

                                 So, if I want the Alt-Tab go to next field and the Ctrl-Tab go to previous field:

                                 Tab or Shift-Tab returns a value of  9 from the Code(Get(ActiveModifierKeys)), Alt returns returns 8 and Ctrl returns 4 from the Get(ActiveModifierKeys).

                                 OnObjectKestroke Triggered by Get(TriggerModifierKeys) or Get(TriggerKeystroke)

                                 If Code(Get(ActiveModifierKeys)) = 9 and Get(ActiveModifierKeys) = 8  //Tab/Skift-Tab and Alt.

                                   Go To Next Field
                                   Exit Script(0)

                                 Else If Code(Get(ActiveModifierKeys)) = 9 and Get(ActiveModifierKeys) = 4  //Tab/Skift-Tab and Ctrl.

                                   Go To Previous Field
                                   Exit Script(0)

                                 End If

                                 Does that look right, not at home atm so I can't test it.

                            • 11. Re: Ctrl-Tab, Ctrl-Enter and Ctrl-NumpadEnter
                              philmodjunk

                                   Minor quibble over your wording. The get functions do not and cannot trigger a script. If you enable one of the two "keystroke" triggers, (There's one for the layout and one you can specify for a field on the layout), ANY key you press will trip the trigger and perform the specified script. What's critical with that detail is that you have to make sure that every possible keystroke is correctly handled by your script. Normally, this is quite easy as you can simply set your script to do nothing when the key that is pressed is not one for which you are trying to script a special response and then the character for that key is simply entered into the active field.

                                   You appear to have some significant confusion over the different get functions. You would not use Code with Get ( ActiveModifierKeys ). This function returns a number that is the sum of the number values assigned to various modifier keys such as shift, ctrl, Alt, option, command... (The last two are Mac keys). The number values assigned to each key are specifically set up so that you get a unique value for any combination of "Down" modifier keys as captured at the instant the script step is performed. You should be using Get ( TriggerModifierKeys ) as this returns the number value for modifier keys that were down at the time the trigger was tripped. The other function may return the same values, or it may not--depending on how quickly the script is performed, so the trigger version is safer.

                                   You'd use the Code function with the Get ( TriggerKeystroke ) function call to get the code for the non-modifier key that was also pressed so that you can identify a key stroke for a key that does not have a visible character. If you look up the code function, you'll see the codes for common keys such as Tab, return and Enter. ("return" is how Mac keyboards label the "Qwerty" Enter key and FileMaker documentation uses this term to distinguish between the Number Pad Enter and Qwerty Enter keys as labeled on a Windows keyboard.)

                                   PS. I have found it useful to set up a test script like this with one of the Keystroke triggers to make sure that what I want to do with my script and my modifier keys will work for me:

                                   Show Custom Dialog ["Modifiers: " & Get ( TriggerModifierKeys ) & "   " & "Key Code": & Code ( Get ( TriggerKeystroke ) ) ]

                                   That way, I can make sure that the modifier key-regular key combination I want to use isn't "pre-empted" by either Filemaker or the OS and I can confirm exactly what code value is being returned if I should need that code.

                              • 12. Re: Ctrl-Tab, Ctrl-Enter and Ctrl-NumpadEnter
                                CekariYH

                                      

                                     

                                          Minor quibble over your wording. The get functions do not and cannot trigger a script. If you enable one of the two "keystroke" triggers, (There's one for the layout and one you can specify for a field on the layout), ANY key you press will trip the trigger and perform the specified script. What's critical with that detail is that you have to make sure that every possible keystroke is correctly handled by your script. Normally, this is quite easy as you can simply set your script to do nothing when the key that is pressed is not one for which you are trying to script a special response and then the character for that key is simply entered into the active field.

                                     I know that, just an under stress writing at work with no FMP or documents close by. :-)

                                      

                                     

                                          You appear to have some significant confusion over the different get functions. You would not use Code with Get ( ActiveModifierKeys ). This function returns a number that is the sum of the number values assigned to various modifier keys such as shift, ctrl, Alt, option, command... (The last two are Mac keys). The number values assigned to each key are specifically set up so that you get a unique value for any combination of "Down" modifier keys as captured at the instant the script step is performed. You should be using Get ( TriggerModifierKeys ) as this returns the number value for modifier keys that were down at the time the trigger was tripped. The other function may return the same values, or it may not--depending on how quickly the script is performed, so the trigger version is safer.

                                     Right, I have read the sections more thoroughly now and understand the difference better now.

                                      

                                     

                                          You'd use the Code function with the Get ( TriggerKeystroke ) function call to get the code for the non-modifier key that was also pressed so that you can identify a key stroke for a key that does not have a visible character. If you look up the code function, you'll see the codes for common keys such as Tab, return and Enter. ("return" is how Mac keyboards label the "Qwerty" Enter key and FileMaker documentation uses this term to distinguish between the Number Pad Enter and Qwerty Enter keys as labeled on a Windows keyboard.)

                                     Yup, got that as well now.

                                      

                                     

                                          PS. I have found it useful to set up a test script like this with one of the Keystroke triggers to make sure that what I want to do with my script and my modifier keys will work for me:

                                     

                                          Show Custom Dialog ["Modifiers: " & Get ( TriggerModifierKeys ) & "   " & "Key Code": & Code ( Get ( TriggerKeystroke ) ) ]

                                     

                                          That way, I can make sure that the modifier key-regular key combination I want to use isn't "pre-empted" by either Filemaker or the OS and I can confirm exactly what code value is being returned if I should need that code.

                                     I was using the same technic last night but couldn't understand when I didn't get anything from Ctrl-Tab and then it was sleep time so i wrote the last one at work in the morning. Still don't know why Ctrl-Tab don't work. Then I went back using Shift-Tab and Alt-Tab.

                                      

                                If Get ( TriggerModifierKeys ) = 8 and Code ( Get ( TriggerKeystroke ) ) = 9  //Alt-Tab

                                       Go To Next Field
                                       Exit Script(0)

                                Else If Get ( TriggerModifierKeys ) = 1 and Code ( Get ( TriggerKeystroke ) ) = 9  //Shift-Tab 

                                      Go To Previous Field
                                       Exit Script(0)

                                     End If

                                     Now the enter field behaves as it should... I think... after some testing :-)

                                • 13. Re: Ctrl-Tab, Ctrl-Enter and Ctrl-NumpadEnter
                                  philmodjunk

                                       Most Ctrl-Key combinations are "Pre-empted" by either FIleMaker or your Operating system and thus never trip the script trigger. My suggested script is a way to quickly test multiple key combinations as a way to see which are pre-empted and which are not.

                                  • 14. Re: Ctrl-Tab, Ctrl-Enter and Ctrl-NumpadEnter
                                    CekariYH

                                         Yes, it's for sure it seems, anyway I got it to work now.