Skip to content

Commit

Permalink
move focus event
Browse files Browse the repository at this point in the history
  • Loading branch information
sprocketc committed Jun 12, 2024
1 parent 3938901 commit 3f61fc1
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 22 deletions.
3 changes: 1 addition & 2 deletions src/renderer/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
[renderer.events]
[renderer.frame.core]
[renderer.history.core]
[renderer.menubar.core]
[renderer.notification.core]
[renderer.panel.core]
[renderer.reepl.core]
Expand Down Expand Up @@ -48,7 +47,7 @@
██╔══██╗██╔══╝░░██╔═══╝░██╔══██║░░░██║░░░██╔══██║
██║░░██║███████╗██║░░░░░██║░░██║░░░██║░░░██║░░██║
╚═╝░░╚═╝╚══════╝╚═╝░░░░░╚═╝░░╚═╝░░░╚═╝░░░╚═╝░░╚═╝
░██████╗████████╗██╗░░░██╗██████╗░██╗░█████╗░
██╔════╝╚══██╔══╝██║░░░██║██╔══██╗██║██╔══██╗
╚█████╗░░░░██║░░░██║░░░██║██║░░██║██║██║░░██║
Expand Down
5 changes: 5 additions & 0 deletions src/renderer/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -218,3 +218,8 @@
(fn [id]
(when-let [element (if id (.getElementById js/document id) (dom/canvas-element))]
(js/setTimeout #(.focus element)))))

(rf/reg-event-fx
:focus
(fn [_ [_ id]]
{:focus id}))
3 changes: 0 additions & 3 deletions src/renderer/menubar/core.cljs

This file was deleted.

8 changes: 0 additions & 8 deletions src/renderer/menubar/events.cljs

This file was deleted.

2 changes: 1 addition & 1 deletion src/renderer/menubar/views.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@
[:> Menubar/Item
{:class "menu-item"
:onSelect #(do (rf/dispatch action)
(rf/dispatch [:menubar/focus nil]))
(rf/dispatch [:focus nil]))
:disabled (when disabled? @(rf/subscribe disabled?))}
label
[:div.right-slot
Expand Down
16 changes: 8 additions & 8 deletions src/renderer/utils/keyboard.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@
(.-shiftKey e) (conj :shift))}]))

(defn input-key-down-handler
"Generic on-key-down handler for input elements that dispatches an event `f`
in order to update a db value on keyboard enter, or reset to the initial
"Generic on-key-down handler for input elements that dispatches an event `f`
in order to update a db value on keyboard enter, or reset to the initial
value `v` on escape.
We need this to avoid updating the canvas with incomplete values while the
We need this to avoid updating the canvas with incomplete values while the
user is typing, and also avoid polluting the history stack.
The `default-value` attribute should be used to update the value reactively."
Expand Down Expand Up @@ -161,19 +161,19 @@
[[:element/select-all]
[{:keyCode (key-codes "A")
:ctrlKey true}]]
[[:menubar/focus "file"]
[[:focus "file"]
[{:keyCode (key-codes "F")
:altKey true}]]
[[:menubar/focus "edit"]
[[:focus "edit"]
[{:keyCode (key-codes "E")
:altKey true}]]
[[:menubar/focus "object"]
[[:focus "object"]
[{:keyCode (key-codes "O")
:altKey true}]]
[[:menubar/focus "view"]
[[:focus "view"]
[{:keyCode (key-codes "V")
:altKey true}]]
[[:menubar/focus "help"]
[[:focus "help"]
[{:keyCode (key-codes "H")
:altKey true}]]
[[:element/move-up]
Expand Down

0 comments on commit 3f61fc1

Please sign in to comment.