2 Replies Latest reply on Dec 13, 2010 10:14 PM by sunmoonstar.13

    Using Enter key for a button

    AndrewClarkson

      Title

      Using Enter key for a button

      Post

      Hopefully a quick question - is it possible to set the enter key on the keyboard to relate to a button in the database?

      Say the user entered a number in a field, and then instead of having to use the mouse to click a button - they could press enter?

      Is it possible to have the cursor jump out of the field after a certain amount of characters - eg if they enter a 7 digit number, then they can press enter without the enter button creating another line in the field?

      Thanks!

        • 1. Re: Using Enter key for a button
          philmodjunk

          I'm guessing you are using FileMaker on Windows. On a Mac, the enter key that's part of the main keyboard is named "return" and the enter key on the numeric keypad is labeled "enter". On windows, they have the same name, but they are not the same key and don't enter the same code when you press them. FileMaker refers to these keys as though they are on a Mac keyboard even if you are using windows.

          If you define your field as a number field instead of text, pressing return will not start a new line of text. You can set field behavior so that pressing tab, return and/or enter moves the cursor to the next field in the tab order. In Filemaker 11, you'll find this in the Inspector under the data tab.

          You can also use script triggers to capture and process each keystroke. The script you associate with this trigger can be written to check for and detect when the return, or enter key is pressed and move the cursor to the next field or do any other action needed.

          • 2. Re: Using Enter key for a button
            sunmoonstar.13

            > Say the user entered a number in a field, and then instead of having to use the mouse to click a button - they could press enter?

             

            If you have FMP v11, you can set up an OnLayoutKeystroke script trigger with the following basic script:

             

            If [ Code (Get (TriggerKeystroke )) = 10 or Code (Get (TriggerKeystroke )) = 13 ]

                Perform Script // Specify the script that you attached to the button

            End If

             

            If the user then presses either of the Enter keys on a Windows keyboard, the script will run as if they had clicked the button.

             

             

            > Is it possible to have the cursor jump out of the field after a certain amount of characters - eg if they enter a 7 digit number, then they can press enter without the enter button creating another line in the field?

             

            Set up an OnObjectModify script trigger on the field with the following basic script:

             

            If [ Length (your_table::your_field) ≥ 7 ]

                Set Field [ your_table::your_field ; Left ( artists::name ; 7 ) ]

                Commit Records/Requests

            End If

             

            If the user enters 7 characters exactly, the cursor jumps out of the field. If the user tries to enter more than 7 characters, the cursor jumps out of the field and the excess characters are removed so that there are never more than 7 characters in the field.

             

            Hope this helps.

             

            Nick