Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Window Activation Trigger

Featured Replies

Sometimes FileMaker developers miss a script trigger to run when you switch between windows. We usually recommend people check if Window.Currentfunction returns a new number. And you may do that with Schedule functions.

 

Here is a script to start a schedule to check the window regularly:

# current window
Set Variable [ $currentWindow ; Value: MBS("Window.Current") ] 
Set Variable [ $r ; Value: MBS( "FM.VariableSet"; "WindowActivateTriggerCurrentWindow"; $currentWindow ) ] 
# Schedule a calculation to check window every second
Set Variable [ $schedule ; Value: MBS( "Schedule.EvaluateAfterDelay"; 1; "Let([
 
lastWindow = MBS( \"FM.VariableGet\"; \"WindowActivateTriggerCurrentWindow\" );
e1 = MBS(\"IsError\"); 
currentWindow = MBS( \"Window.Current\" );
e2 = MBS(\"IsError\");
 
r = If(e1 = 0 AND e2 = 0 AND lastWindow ≠ currentWindow; Let([
 
	w = MBS( \"FM.VariableSet\"; \"WindowActivateTriggerCurrentWindow\"; currentWindow );
	e = MBS( \"FM.RunScript\"; \"" & Get(FileName) & "\"; \"Window Activated Trigger\")
 
]; 0); 0)
 
];1)"; ""; ""; 1 ) ] 
Set Variable [ $r ; Value: MBS( "FM.VariableSet"; "WindowActivateTrigger"; $schedule ) ] 

As you see, we use a variable via MBS Plugin to store the number of the current window independent of the scope of $$ variables. The calculation is evaluated once a second (when FileMaker is not busy) and if we get the window number, we remember it and trigger the script.

 

To stop the trigger, we can release the schedule:

# stop trigger if it is running
If [ MBS( "FM.VariableExists"; "WindowActiateTrigger" ) ] 
	Set Variable [ $w ; Value: MBS( "FM.VariableGet"; "WindowActivateTrigger" ) ] 
	Set Variable [ $r ; Value: MBS("Schedule.Release"; $w) ] 
	Set Variable [ $r ; Value: MBS( "FM.VariableClear"; "WindowActivateTrigger" ) ] 
	Set Variable [ $r ; Value: MBS( "FM.VariableClear"; "WindowActivateTriggerCurrentWindow" ) ] 
End If

Please try and comment. Let us know if you have questions. The example database will be included with the next pre-release.

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.