Skip to content

Commit

Permalink
Don't execute shortcuts if the rundown isn't focused
Browse files Browse the repository at this point in the history
Signed-off-by: Axel Boberg <[email protected]>
  • Loading branch information
axelboberg committed Feb 18, 2024
1 parent 4b436db commit df065cf
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
13 changes: 13 additions & 0 deletions docs/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -350,10 +350,23 @@ Shortcut triggers can be overridden by the user in the settings panel.
Listen to a registered shortcut by subscribing to the `shortcut` event.
When triggered the action will be provided as the listeners first argument as such:

**Note: The shortcut event will ONLY be fired inside widgets, not in the plugin's main script.**

```javascript
import bridge from 'bridge'

bridge.events.on('shortcut', action => {
/*
It's your responibility to abort actions if they're not
expected to be triggered if the widget isn't in focus
Check the `bridgeFrameHasFocus` property on the window
object before reacting to the action
*/
if (!window.bridgeFrameHasFocus) {
return
}

console.log('Shortcut was triggered for action:', action)
// React to action
})
Expand Down
8 changes: 8 additions & 0 deletions plugins/rundown/app/components/RundownList/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,14 @@ export function RundownList ({

React.useEffect(() => {
function onShortcut (shortcut) {
/*
Don't execute any shortcuts
if the frame isn't focused
*/
if (!window.bridgeFrameHasFocus) {
return
}

switch (shortcut) {
case 'bridge.rundown.next':
select(1)
Expand Down

0 comments on commit df065cf

Please sign in to comment.