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.