Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spinner Example #154

Open
dsbw opened this issue Jan 20, 2022 · 0 comments
Open

Spinner Example #154

dsbw opened this issue Jan 20, 2022 · 0 comments

Comments

@dsbw
Copy link

dsbw commented Jan 20, 2022

I made a spinner example, which might be helpful.

(ns ezclj.utils.spinner
  (:require [cljfx.api :as fx]
            [clojure.core.cache :as cache]))

(def ctx
  (atom (fx/create-context
          {}
          cache/lru-cache-factory)))

(defn view [{:keys [fx/context]}]
  {:fx/type :stage
   :showing true
   :scene   {:fx/type :scene
             :root    {:fx/type    fx/ext-on-instance-lifecycle
                       :desc       {:fx/type :spinner
                                    :value-factory {:fx/type :integer-spinner-value-factory
                                           :amount-to-step-by 1
                                           :min 2000
                                           :max 2050
                                           :value 2022}
                                    }}}})

(def renderer
  (fx/create-renderer
    :middleware (comp fx/wrap-context-desc (fx/wrap-map-desc (fn [_] {:fx/type view})))))

(fx/mount-renderer ctx renderer)

I was not able to figure out how to get a text-formatter in there. If the spinner is editable, the user can type in letters (and this causes an NumberFormatException in this example when the window is closed. (This surprised me, I don't know where the conversion is attempted.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant