Remembering tabs or panels across FileMaker layouts
In a recent discussion with another FileMaker developer, we were singing the praises of the popular Browser Navigation module from Paul Jansen. We've been using it for a few years now and I see it more all the time. It's also used in Geist Interactive's open framework, Karbon (Github).
How do we remember what tab the user was on when we come back?
That was a challenge we needed to meet head-on as many users find it frustrating to jump some place else in the app to look at other information, only to come back to the original layout and loose their focus because when they left, they were on Team tab and now they're on the Summary tab.
The Solution
Here's what we do... we have a modular script we call
gotoPanel ( entity ; object ; nav )
First off, we don't use FileMaker's native tabs. There were limitations on styling them as well as some constraints that required work-arounds. Overall, while they serve a purpose, we have incorporated button bars and slide controls, which we find more flexible.
Assuming a layout is based on an entity, we set a global specific for that entity and check for its existence and go to that object when we land back on our original layout.
This technique requires an onLayoutEnter script trigger.
Step 1 - Name your button bar object. We'll call this company.tabs (company being our entity).
Step 2 - Name your individual buttons in the button bar:
company_tab.1
company_tab.2
company_tab.3
...
Step 3 - Name your panels in your slide control:
company_panel.1
company_panel.2
company_panel.3
...
When the user clicks a button bar, we run our script, passing parameters:
Let ([
n = 1 ;
entity = "company"
] ;
JSONSetElement ( "{}";
[ "entity" ; entity ; JSONString ] ;
[ "object" ; entity & "_panel." & n ; JSONString ] ;
[ "nav" ; entity & ".tabs" ; JSONString ]
)
)
This is broken out with local variables in the Let statement so that we can use this across our solution, only chancing the "n" and "entity" when we need to.
The script itself is straight forward. We simply assign a global as follows:
"TAB." & $entity ; $object = $$TAB.company = company_panel.1
Completion
When we do return to our original layout, we run our script trigger onLayoutEnter ( entity ). The layout passes the correct entity (in this case "company").
# we're always getting our parameters... JSON Set Variable [ $! ; Value: JSONCreateVarsFromKeys ( Get ( ScriptParameter ) ; "" ) ] # If [ not IsEmpty ( Evaluate ( "$$TAB." & $entity ) ) ] Perform Script [ Specified: From list ; "gotoPanel ( object { ; focus ; refresh_object } )" ; Parameter: JSONSetElement ( "{}"; ["entity"; $entity ; JSONString] ; ["object"; Evaluate ( "$$TAB." & $entity ) ; JSONString] ; ["nav"; $entity & ".tabs" ; JSONString] ) ] End If