This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-11-15
Channels
- # announcements (1)
- # asami (29)
- # babashka (31)
- # beginners (48)
- # calva (39)
- # cljsrn (4)
- # clojure (56)
- # clojure-dev (51)
- # clojure-doc (3)
- # clojure-europe (40)
- # clojure-gamedev (13)
- # clojure-italy (22)
- # clojure-nl (3)
- # clojure-uk (5)
- # cursive (9)
- # datomic (184)
- # events (7)
- # fulcro (8)
- # graalvm (2)
- # jobs (1)
- # malli (6)
- # meander (1)
- # nrepl (5)
- # off-topic (10)
- # pathom (9)
- # polylith (33)
- # portal (2)
- # re-frame (7)
- # reagent (12)
- # releases (3)
- # remote-jobs (3)
- # reveal (27)
- # shadow-cljs (34)
- # sql (1)
- # vim (7)
- # xtdb (62)
I have an action that uses a :tree-view
. After executing the action, the tree view opens, but I can no longer use my escape key to close the results panel. If I click the escape key, nothing happens whereas I expect the results panel to close. I'm guessing it has something to do with the "Editing" mode of a https://docs.oracle.com/javase/8/javafx/api/javafx/scene/control/TreeView.html, but I'm not sure. Any idea what causes this and how I might disable it to get Reveal's usual behavior of closing the result panel on the escape key press?
Example treeview action:
(rx/defaction ::example-tree-view [x]
(when (::example-tree-view x)
(fn []
{:fx/type :tree-view
:root {:fx/type :tree-item
:value "Inbox"
:children [{:fx/type :tree-item
:value "Email 1"}]}})))
@U47G49KHQ any idea on this?
This is a problem with default tree view behavior consuming not only escape key press, but also ctrl+up/left/right that is used by reveal results panel for navigation between different results
the workaround is to re-configure tree view so it does not handle escape and ctrl+left/up/right at all
Here is how to do it:
(require '[vlaaad.reveal.ext :as rx]
'[cljfx.api :as fx])
(import '[javafx.scene.input KeyEvent KeyCode]
'[javafx.scene.control TreeView]
'[javafx.event EventDispatcher])
(defn- init-tree-view! [^TreeView tree-view]
(let [dispatcher (.getEventDispatcher tree-view)]
(.setEventDispatcher tree-view
(reify EventDispatcher
(dispatchEvent [_ e next]
(if (and (instance? KeyEvent e)
(or (and
(.isShortcutDown ^KeyEvent e)
(#{KeyCode/UP KeyCode/DOWN KeyCode/LEFT KeyCode/RIGHT} (.getCode ^KeyEvent e)))
(= KeyCode/ESCAPE (.getCode ^KeyEvent e))))
e
(.dispatchEvent dispatcher e next)))))))
(rx/defaction ::example-tree-view [x]
(when (::example-tree-view x)
(fn []
{:fx/type fx/ext-on-instance-lifecycle
:on-created init-tree-view!
:desc {:fx/type :tree-view
:root {:fx/type :tree-item
:value "Inbox"
:children [{:fx/type :tree-item
:value "Email 1"}]}}})))
Thank you for that snippet. That will make working on the clojure.test integration sooooo much easier. Might I suggest adding it to the https://github.com/vlaaad/reveal/tree/master/examples?
Awesome. You would laugh at how often I had to restart reveal because I just wanted to results panel closed 😅
Heh. You can always click on results panel title (e.g. (example-tree-view {...})
) and then use backspace to close selected tab
Separately, I noticed that the tree view has some odd styling issues. The toggle arrow seems to appear & disappear for the below tree-view (see screenshot with missing toggle)
{:fx/type :tree-view
:root {:fx/type :tree-item
:value "Inbox"
:children [{:fx/type :tree-item
:value "Email 1"}]}}
It's a styling issue! I made some improvements to tree-view styling before for paid version and now imported those changes to free version, please update to 1.3.228
to get better tree-view styling