11 Replies Latest reply on Nov 18, 2009 12:26 PM by DrDave

    Assign Key to Button

    DrDave

      Title

      Assign Key to Button

      Post

      I have a simple layout that contains two buttons: <Previous> and <Next>. They simply move to the previous or next record.

       

      What do I have to do so that if the user press the page-up or page-down key, the same thing happens?

       

      All suggestions appreciated.... 

       

        • 1. Re: Assign Key to Button
          hiatts
             Try a layout script trigger, onkeystroke, and in the receiving script use Get(TriggerKeystroke) to catch the key pressed on the layout. 
          • 2. Re: Assign Key to Button
            Jade
               If you are using Mac OS X, add two application shortcuts for FMP (System Preferences>Keyboard>Keyboard Shortcuts>Application Shortcuts) with the page-up key set to "Previous" and the page-down key set to "Next".
            • 3. Re: Assign Key to Button
              DrDave
                

              Thank you...this sounds interesting.

               

              I do know a bit about FMP (v10). but I have not got into the triggers.

               

              Can you help me get started as to how I would set this up. Much appreciated. 

              • 4. Re: Assign Key to Button
                DrDave
                  

                Good suggestion for Mac users. This application get used in both Mac and PC environments.

                 

                Thank you for your suggestions...it will work for me when I'm developing, which is on a Mac.

                 

                 

                • 5. Re: Assign Key to Button
                  raybaudi
                    

                  Hi

                   

                  try something like this:

                   

                  1) create a script:

                   

                  If [ Code ( Get ( TriggerKeystroke ) ) = 2 ]
                  Scoll Window [ Page Up ]
                  End If
                  If [ Code ( Get ( TriggerKeystroke ) ) = 3 ]
                  Scoll Window [ Page Down ]
                  End If

                   

                  2) While in Layout Mode: Layouts >> Layout Setup... >> Script Triggers ( tab ) >> check the OnLayoutKeystroke and select the bove script.



                  • 6. Re: Assign Key to Button
                    DrDave
                      

                    Perfecto!

                     

                    I actually used the GoToRecord previous/next script command.

                     

                    In addition, rather than using two separate script, I used the If, else if, commands. With two separate if statements, they both get evaluated ALL the time. If "if else," the second condition will not get evaluated if the first condition is true.

                     

                    Thank you so much for your help. This is VERY handy. 

                    • 7. Re: Assign Key to Button
                      DrDave
                        

                      A follow-up question if I may.

                       

                      I see there is a trigger allowance for OnRecordLoad. For that condition, I want to ensure that the cursor is placed in a specified field (score1).

                       

                      I thought I could use set field, but that does not work.

                       

                      Appreciate the feedback. 

                      • 8. Re: Assign Key to Button
                        raybaudi
                          

                        DrDave wrote:

                         

                        I actually used the GoToRecord previous/next script command.


                        Of course, I wrote the wrong script steps

                        • 9. Re: Assign Key to Button
                          philmodjunk
                            

                          You can use Go To Field to put the cursor in a specified field.

                           

                          Use triggers like OnRecordLoad and OnLayoutLoad with caution. If you have anyother scripts that use Go To Record or Go To Layout (this layout), they'll activate the trigger also.

                          • 10. Re: Assign Key to Button
                            raybaudi
                              

                            DrDave wrote:

                             

                            I see there is a trigger allowance for OnRecordLoad. For that condition, I want to ensure that the cursor is placed in a specified field (score1).


                            You do not need a script trigger to position the cursor into that field.

                             

                            Simply give it the number one in the tab order

                            • 11. Re: Assign Key to Button
                              DrDave
                                

                              Worked perfectly and thank you for the heads-up. 

                               

                              I already "discovered" one of those conditions. If you have the debugger on, then you actually see what is being executed when.

                               

                              In this particular instances, what you warn against is exactly what I want! Bonus. :-)