EventMonitor.SetCardWindow
--------------------------

Sets script trigger for clicks outside card.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [EventMonitor](component_EventMonitor.md) | [7.3](newinversion73.md) | ✅ Yes | ✅ Yes | ❌ No | ❌ No | ❌ No |

MBS( "EventMonitor.SetCardWindow"; WindowRef; X; Y; Width; Height; FileName; ScriptName { ; ScriptParameter; ScriptControl } ) 

**MBS**( **"EventMonitor.SetCardWindow";** /\* Sets script trigger for clicks outside card. \*/  
**$WindowRef**; /\* Window Reference is the unique OS level window ID. You can obtain this by using the [Window.FindByTitle](WindowFindByTitle.md) or [Window.FindByIndex](WindowFindByIndex.md) functions. Pass zero to access the frontmost window.e.g. 0 \*/   
**$X**; /\* X position of the card in the parent window.  
Can be negative for automatic center position.e.g. -1 \*/   
**$Y**; /\* Y position of the card in the parent window.  
Can be negative for automatic center position.  
You may need to include space for formating, status toolbar and menu bar (inside window on Windows).e.g. -1 \*/   
**$Width**; /\* The width of the card window.e.g. 600 \*/   
**$Height**; /\* The height of the card window.e.g. 400 \*/   
**$FileName**; /\* The file name where to find the script.e.g. Get(FileName) \*/   
**$ScriptName**; /\* The name of the script to trigger when a click is received outside the card area.e.g. "Close Card Script" \*/   
**$ScriptParameter**; /\* Optional; The text parameter to pass to the script.e.g. "Close" \*/   
**$ScriptControl**) /\* Optional; The script control mode.  
Can be Pause, Halt, Exit or Resume.  
Default is Pause.  
  
May be ignored by FileMaker.e.g. "pause" \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| WindowRef | Window Reference is the unique OS level window ID. You can obtain this by using the [Window.FindByTitle](WindowFindByTitle.md) or [Window.FindByIndex](WindowFindByIndex.md) functions. Pass zero to access the frontmost window. | 0 |  |
| X | X position of the card in the parent window.   Can be negative for automatic center position. | -1 |  |
| Y | Y position of the card in the parent window.   Can be negative for automatic center position.   You may need to include space for formating, status toolbar and menu bar (inside window on Windows). | -1 |  |
| Width | The width of the card window. | 600 |  |
| Height | The height of the card window. | 400 |  |
| FileName | The file name where to find the script. | Get(FileName) |  |
| ScriptName | The name of the script to trigger when a click is received outside the card area. | "Close Card Script" |  |
| ScriptParameter | The text parameter to pass to the script. | "Close" | Optional      Added in version **9.3**. |
| ScriptControl | The script control mode.   Can be Pause, Halt, Exit or Resume.   Default is Pause.      May be ignored by FileMaker. | "pause" | Optional      Added in version **9.3**. |

### Result

Returns OK or error.

### Description

Sets script trigger for clicks outside card.  
You can show a card and have the MBS Plugin watch for mouse clicks outside the card area. The plugin can trigger a script. As script triggers are queued up, please make sure you handle various cases like several clicks queue up.  
  
Please call [EventMonitor.Install](EventMonitorInstall.md) once before and make sure it’s enabled.  
  
Since we lookup the window size for the card, please don't name your window and the card window the same.  
  
  
With plugin version 6.0 or newer the script name can be a script ID number. In that case the plugin queries the script name for the given script ID. This allows to call scripts by ID and avoid problems if scripts are later renamed.  
  
Notice: FileMaker 19.2 adds a fmplugin extended privileges. If you have such an extended privileges to allow the plugin to trigger scripts, you need to grant permissions for it. If such a privilege is not defined, the plugin is allowed to trigger scripts. See FileMaker product documentation for details.  
### Examples

Install trigger:

 Set Variable \[ $r ; Value: MBS ( "[EventMonitor.Install](EventMonitorInstall.md)" ) \]   
Set Variable \[ $$cardShowing ; Value: 1 \]   
Set Variable \[ $r ; Value: MBS ( "EventMonitor.SetCardWindow"; Get(WindowName); -1; -1; 600; 400; Get(FileName); "Close Script" ) \]   
New Window \[ Style: Card ; Name: "Card" ; Using layout: “Tabelle” ; Height: 400 ; Width: 600 \]  
Close script:

 If \[ $$cardShowing \]   
 Set Variable \[ $$cardShowing ; Value: 0 \]   
 Close Window \[ Name: "Card" ; Current file \]   
 Set Variable \[ $r ; Value: MBS ("[EventMonitor.ClearCardWindow](EventMonitorClearCardWindow.md)") \]   
End If  
### See also

- [EventMonitor.Clear](EventMonitorClear.md)
- [EventMonitor.ClearCardWindow](EventMonitorClearCardWindow.md)
- [EventMonitor.Install](EventMonitorInstall.md)
- [Window.FindByIndex](WindowFindByIndex.md)
- [Window.FindByTitle](WindowFindByTitle.md)

### Release notes

- **Version 9.3**
    - Added mode parameter to [FM.RunScript](http://www.mbsplugins.eu/FMRunScript.shtml) and [EventMonitor.SetCardWindow](http://www.mbsplugins.eu/EventMonitorSetCardWindow.shtml) functions.
    - Added parameter for script parameter for [EventMonitor.SetCardWindow](http://www.mbsplugins.eu/EventMonitorSetCardWindow.shtml) function.
- **Version 7.3**
    - Added [EventMonitor.ClearCardWindow](http://www.mbsplugins.eu/EventMonitorClearCardWindow.shtml) and [EventMonitor.SetCardWindow](http://www.mbsplugins.eu/EventMonitorSetCardWindow.shtml) to handle clicks outside a card window.

### Example Databases

- [Window/Card Window Test](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Window/Card%20Window%20Test.shtml#1ScriptAnchor_)
- [Window/Popover CardWindow](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Window/Popover%20CardWindow.shtml#1ScriptAnchor_)

### Blog Entries

- [MBS FileMaker Plugin, version 9.3pr1](https://www.mbsplugins.de/archive/2019-06-03/MBS_FileMaker_Plugin_version_9/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 7.3pr1](https://www.mbsplugins.de/archive/2017-06-05/MBS_FileMaker_Plugin_version_7/monkeybreadsoftware_blog_filemaker)
- [FileMaker 16 Card Window hacks with MBS Plugin](https://www.mbsplugins.de/archive/2017-06-03/FileMaker_16_Card_Window_hacks/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 2nd June 2017 , last changed 4th August 2025

  
[EventMonitor.LastMousePositionY](EventMonitorLastMousePositionY.md) - [EventMonitor.SetEnabled](EventMonitorSetEnabled.md)

[HTML Version](EventMonitorSetCardWindow.shtml)