4 Replies Latest reply on Mar 4, 2014 11:09 AM by rmittelman

    Scroll List Layout by Keystroke


      I have a typical list layout, showing many records, and I'd like to be able to jump to a point in the list by tapping that record's first letter. This seems like a common feature request.


      In MS Access, I would turn on KeyPreview for the form and hook into the form's KeyPress event, scrolling the list. So here's my 2 questions:


      1: How can I accomplish this in FMP? (note, there are no actual fields on this list layout to land on, just <<fields>>)


      2: If I can do this, how would I scroll to that letter in the list without necessarily making the first record of that letter the active record? I know I can scroll window to the active record, but is there any way to scroll the window to the desired record WITHOUT making it active? ** This question is of lesser importance, as I will make that record active if necessary **



        • 1. Re: Scroll List Layout by Keystroke

          You can try out the OnLayoutKeystroke to trigger a script. Then either use a loop, or the "Scroll Window" script step to position.



          Something like this would work:

          Set Variable $letter = Get(TriggerKeystroke)


             Go To Record [next]

             Exit Loop if [ left (field ; 1 ) = $letter OR get(recordnumber) = get(foundcount)]

          End Loop


          A more common practice in FM is mapping the up and down arrows to page up and down (also, home, end, etc..)


          I believe you will have to make a record active to check the first letter you are looking to correspond to (as noted in the loop above), although you can script around this creatively if you need.

          • 2. Re: Scroll List Layout by Keystroke

            The equivalent of the "KeyPress" event to which you refer is the OnLayoutKeystroke Script Trigger. It's found in the Layout Setup dialog, under Script Triggers:





            Of course, you'll need to write a script to invoke on that event. That script will need to do the work of scrolling the layout. I'm not entirely sure what you mean by "first record of that letter"; presumably, you have some sort of address book list? But you should be able to write a script that will scroll to the appropriate record by comparing the keystroke (using the Get ( TriggerKeystroke ) function) against the first letter of whatever field you're wanting to capture.


            And no, I don't believe there's a way to avoid making it the active record. Someone else may know of a way, but the Go to Record script step inherently sets the current record to the result of the calculation, and I can't think of a way to make the Scroll Window script step work off the top of my head.





            1 of 1 people found this helpful
            • 3. Re: Scroll List Layout by Keystroke

              Thanks Mike, that worked just fine.  Only differences I needed were to move to first record before loop, and then reverse the order of the 2 statements in the loop, because it would never stay on the first record otherwise.

              • 4. Re: Scroll List Layout by Keystroke

                Thanks for the reply Mike.  Sorry I couldn't give you credit for the answer, as the other Mike got in first.  I did mark it helpful, though.