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?
@vlaaad any idea on this?
I'm boarding a plane right now :D
Will look at it a bit later...
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?
you mean adding snippet to the examples?
or clojure.test integration?
First one
Sure, I can do that
Awesome. You would laugh at how often I had to restart reveal because I just wanted to results panel closed 😅
https://github.com/vlaaad/reveal/blob/master/examples/e09_results_panel_tree_view.clj
Heh. You can always click on results panel title (e.g. (example-tree-view {...})) and then use backspace to close selected tab
TIL. Thank you. How could I have discovered that myself?
I may be missing it, but doesn't that just document the ECS key to close the tab?
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"}]}})))Oh, backspace isn't documented there..
I should create one universal shortcut that shows all available shortcuts...
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
Oh awesome! Thanks for verifying -- I'm still really new to cljfx, but knowing that should help me debug oddities like that in the future.
(happy to switch to the paid version once I can actually switch my repl over to reveal 🙂 )
Clicking a row also does not visibly select the row. Perhaps a styling thing?