Skip to content

Commit

Permalink
feat(global-shortcut): support pressed/released states (#1244)
Browse files Browse the repository at this point in the history
closes #1243
  • Loading branch information
amrbashir committed Apr 24, 2024
1 parent a913216 commit 9c7eb35
Show file tree
Hide file tree
Showing 18 changed files with 86 additions and 41 deletions.
11 changes: 11 additions & 0 deletions .changes/global-hotkey-event.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
"global-shortcut": "patch"
"global-shortcut-js": "patch"
---

Refactored APIs to introduce new pressed and released events:

- Added `ShortcutEvent` and `ShortcutState` types in Rust.
- Changed the handler function passed to `GlobalShortcut::on_shortcut`, `GlobalShortcut::on_all_shortcuts` and `Builder::with_handler` to take a 3rd argument of type `ShortcutEvent`.
- Added `ShortcutEvent` interface in JS.
- Changed `ShortcutHandler` type alias (which affects the JS `register` and `registerAll` APIs) to take `ShortcutEvent` instead of a string.
10 changes: 7 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions examples/api/src/views/Shortcuts.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
function register() {
const shortcut_ = shortcut;
registerShortcut(shortcut_, () => {
onMessage(`Shortcut ${shortcut_} triggered`);
registerShortcut(shortcut_, (e) => {
onMessage(`Shortcut ${shortcut_} triggered ${e.state}`);
})
.then(() => {
shortcuts.update((shortcuts_) => [...shortcuts_, shortcut_]);
Expand Down
2 changes: 1 addition & 1 deletion plugins/clipboard-manager/api-iife.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/deep-link/api-iife.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9c7eb35

Please sign in to comment.