Skip to content

Commit 3f61fc1

Browse files
committed
move focus event
1 parent 3938901 commit 3f61fc1

File tree

6 files changed

+15
-22
lines changed

6 files changed

+15
-22
lines changed

src/renderer/core.cljs

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
[renderer.events]
2121
[renderer.frame.core]
2222
[renderer.history.core]
23-
[renderer.menubar.core]
2423
[renderer.notification.core]
2524
[renderer.panel.core]
2625
[renderer.reepl.core]
@@ -48,7 +47,7 @@
4847
██╔══██╗██╔══╝░░██╔═══╝░██╔══██║░░░██║░░░██╔══██║
4948
██║░░██║███████╗██║░░░░░██║░░██║░░░██║░░░██║░░██║
5049
╚═╝░░╚═╝╚══════╝╚═╝░░░░░╚═╝░░╚═╝░░░╚═╝░░░╚═╝░░╚═╝
51-
50+
5251
░██████╗████████╗██╗░░░██╗██████╗░██╗░█████╗░
5352
██╔════╝╚══██╔══╝██║░░░██║██╔══██╗██║██╔══██╗
5453
╚█████╗░░░░██║░░░██║░░░██║██║░░██║██║██║░░██║

src/renderer/events.cljs

+5
Original file line numberDiff line numberDiff line change
@@ -218,3 +218,8 @@
218218
(fn [id]
219219
(when-let [element (if id (.getElementById js/document id) (dom/canvas-element))]
220220
(js/setTimeout #(.focus element)))))
221+
222+
(rf/reg-event-fx
223+
:focus
224+
(fn [_ [_ id]]
225+
{:focus id}))

src/renderer/menubar/core.cljs

-3
This file was deleted.

src/renderer/menubar/events.cljs

-8
This file was deleted.

src/renderer/menubar/views.cljs

+1-1
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@
528528
[:> Menubar/Item
529529
{:class "menu-item"
530530
:onSelect #(do (rf/dispatch action)
531-
(rf/dispatch [:menubar/focus nil]))
531+
(rf/dispatch [:focus nil]))
532532
:disabled (when disabled? @(rf/subscribe disabled?))}
533533
label
534534
[:div.right-slot

src/renderer/utils/keyboard.cljs

+8-8
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@
3333
(.-shiftKey e) (conj :shift))}]))
3434

3535
(defn input-key-down-handler
36-
"Generic on-key-down handler for input elements that dispatches an event `f`
37-
in order to update a db value on keyboard enter, or reset to the initial
36+
"Generic on-key-down handler for input elements that dispatches an event `f`
37+
in order to update a db value on keyboard enter, or reset to the initial
3838
value `v` on escape.
3939
40-
We need this to avoid updating the canvas with incomplete values while the
40+
We need this to avoid updating the canvas with incomplete values while the
4141
user is typing, and also avoid polluting the history stack.
4242
4343
The `default-value` attribute should be used to update the value reactively."
@@ -161,19 +161,19 @@
161161
[[:element/select-all]
162162
[{:keyCode (key-codes "A")
163163
:ctrlKey true}]]
164-
[[:menubar/focus "file"]
164+
[[:focus "file"]
165165
[{:keyCode (key-codes "F")
166166
:altKey true}]]
167-
[[:menubar/focus "edit"]
167+
[[:focus "edit"]
168168
[{:keyCode (key-codes "E")
169169
:altKey true}]]
170-
[[:menubar/focus "object"]
170+
[[:focus "object"]
171171
[{:keyCode (key-codes "O")
172172
:altKey true}]]
173-
[[:menubar/focus "view"]
173+
[[:focus "view"]
174174
[{:keyCode (key-codes "V")
175175
:altKey true}]]
176-
[[:menubar/focus "help"]
176+
[[:focus "help"]
177177
[{:keyCode (key-codes "H")
178178
:altKey true}]]
179179
[[:element/move-up]

0 commit comments

Comments
 (0)