When a user selects a value from a drop-down list, FileMaker’s expected behaviour is to move the cursor automatically to the next field (or object) in the tab order. If that field also has a drop-down list attached, this will have the effect of activating the list.
Under normal circumstances, this is fine and even desirable. But sometimes you don’t want this to happen, and there is no native option to prevent the cursor from jumping to the next object after a user selects from a list.
Why would you want to do this in the first place? Well, I was creating a global search field at the top of a layout with a drop-down list attached, and a script trigger On Object Save that finds a set of records corresponding to the user’s list selection. I wanted it to stay on the field after the user selected an item from the list, since the interaction is essentially over at that point.
But it kept jumping and selecting the next object in the tab order, which in this case was a tab panel. I could of course remove all non-field objects from the tab order to prevent that, but then it would just jump to a field instead. I wanted it to stay where it was (essentially, do nothing) after the list selection.
In the past, I’ve used a second field, identical to the first—but without a drop-down list—as the next object. Then, when the selection jumps, it jumps to “itself,” and the user doesn’t see any change (which is what you want).
But this didn’t quite work how I wanted. Whenever the cursor jumped to the second field, it highlighted the contents of the field in white. As I was using white text on a coloured background, all the user ends up seeing is a white box.
There is no way I could see to remove the white field fill (FileMaker doesn’t recognize it as a “fill”). I could work around it by changing the In Focus options on the field to make the text black instead of white, but it still wasn’t quite what I was looking for.
I solved the problem by using the same technique, but adding a script trigger to the second field that runs when the field is entered (which happens as a result of the drop-down list selection) and commits the record.
Here are the detailed steps:
- Create a script that contains one step: Commit Records/Requests (no dialog).
- Select your first field (the one with the drop-down list) and create a copy of it. Remove the value list and any existing script triggers from the copy.
- Attach a script trigger to the copied field that activates this script On Object Enter.
- Make sure the copied field is the next field in the tab order (Layouts > Set Tab Order) after your first field.
- Align both fields vertically and horizontally so they are exactly on top of each other.
- Select the copy and send it to the back of the original, so that the original (with the list) is on top.
That’s it! Now, when the user selects the list, nothing happens, which is exactly what you want!
UPDATE: In addition to adopting the method suggested by Matt Petrowsky in the comments below (instead of using a copied field, use Exit Script [Result: False]) to prevent the jump, I also changed the script trigger to an On Object Modify. This was because to clear their selection with On Object Save, the user had to remove the text, then click out of the field to have their results update. On Object Modify has the effect of leaving the field immediately as soon as the field text is removed.
Alexis, try using the OnObjectExit trigger (on your original field – no copies) and attaching it to a script which simply uses Exit Script [ Result: False ]
This will prevent FileMaker from continuing anything it would otherwise normally do – such as moving to the next field in the tab order.
Exiting from any trigger with False is helpful in many situations.
Great solution, I adopted the OnObjectExit trigger with the Exit Script step and it works like charm – many thanks!
Sorry, on the previous comment, you likely don’t need the OnObjectExit. You should just be able to use the Exit Script False on your OnObjectSave of the Drop down list.
Thanks Matt, that’s very handy and helpful! I never thought of using the Script Result that way.
For those who want an explanation of the use of the Script Result [False], here’s the link to a FileMaker Help article explaining it. http://www.filemaker.com/help/11/fmp/html/script_trigg.38.7.html
I’ve been looking for the answer to this nagging ‘issue’. Thanks!!
Unless you want something to happen. I normally have two triggers on every drop-down (pop-up) menu:
1. The first one runs a script onObjectModify that has one script step: commit.
2. The second one runs onObjectSave and that does something with the selected text.
The commit helps me get the contents of the global field so I can use it.
That makes sense. I’ve gotten away from drop-down lists a bit lately, since the ones I use most have so many values and they get so slow as to be unusable. In those cases, I’ve been using a portal formatted like a list instead, with a type-ahead field at the top to filter the values.
But drop-downs do have their uses at times! Thanks Agnes.
Is there any reason you wouldn’t bypass this behaviour by using the Go To Field  script step and not selecting a field to jump to? I’ve used this technique and it works with both Drop Down and Pop Up menus – I haven’t found any issues with it yet but of course there’s always the possibility that FM might force you to select a field in a future s/w release (though I doubt it).
Looks like I forgot to mention that this would be twinned with an OnObjectModify script trigger for the field in question.
It seems that this would also work! Although if you were to do a BaseElements scan or similar on the file at some point, you might get an error that the field wasn’t specified.
Thanks for your contribution!
Thanks Jon for this.
It’s work great,
thank you for teach us
Nice and simple logic.
Thanks a bunch.
Thank you Agnes and Alexis for providing details and alternate ideas. This is still helpful.
I create a ‘Focus’ script that triggers on modify and then goes to an empty field elsewhere on the layout (or a different layout) without selecting it.
Not sure if this is still active …
Simply selecting the value in the value list by using the Enter key (or Fn-Return) instead of the Return key keeps the cursor/focus on the current field …