humbleui

Danil Shingarev 2024-03-24T21:05:56.379749Z

I know I’m most likely doing something stupid but I was playing with my controls a little bit today and stumbled on an issue I can’t figure out. Attached the recording. I can’t figure out focusable on text-field. I see it’s working in humble-ui demo, but I have no idea what am I doing wrong. I tested with regular text-fields instead of customized and getting the same result.

Danil Shingarev 2024-03-24T21:06:02.109049Z

This is how I include sidebar block from the main:

...
(ui/dynamic _ [current-name @state/*chapter
               sidebar (when (= current-name name) (get-in chapters [name :sidebar]))]
  (if sidebar
    sidebar
    (ui/gap 0 0)))
...
and chapter’s sidebard code:
(def ui
  (ui/with-scale scale
    (let [padding-inner  12
          fill-bg        (paint/fill 0xFFFFFFFF)
          stroke-bg      (paint/stroke 0xFFE0E0E0 (* 0.5 scale))]
        (ui/valign 0
          (ui/rect fill-bg
            (ui/rect stroke-bg
              (ui/padding padding-inner 0
                (ui/column
                  (sidebar/control-group "Ray Position:")
                  (ui/row
                    [:stretch 0.4 (xui/number-field {:label "Z"} state/*z)]
                    (ui/gap padding-inner 0)
                    [:stretch 0.4 (xui/number-field {:label "Y"} state/*y)])
                  ;; tested with standard text-field
                  #_(ui/row
                      [:stretch 0.4 (ui/text-field state/*z')]
                      (ui/gap padding-inner 0)
                      [:stretch 0.4 (ui/text-field state/*y')])
                  sidebar/delimiter
                  (sidebar/slider "Angle:" state/*angle :suffix "°")
                  sidebar/delimiter
                  (ui/gap 0 padding-inner)))))))))

Niki 2024-03-25T15:25:56.244409Z

Might just be a bug, focusable is not very good yet

Niki 2024-03-25T15:26:10.001359Z

One thing to try: put focus-controller over everything

👍 1
Niki 2024-03-25T15:27:04.893959Z

I was meaning to make it automatic eventually but right now you have to do it manually

Danil Shingarev 2024-03-25T15:50:15.796329Z

Will test in a bit thank you

Danil Shingarev 2024-03-25T22:17:40.656959Z

focus-controller did the trick.

👍 1