This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-05-22
Channels
- # announcements (4)
- # babashka (10)
- # beginners (25)
- # biff (4)
- # calva (22)
- # clj-on-windows (3)
- # clj-otel (1)
- # clojure (17)
- # clojure-europe (5)
- # clojure-gamedev (2)
- # clojure-norway (1)
- # clojurescript (21)
- # conjure (5)
- # core-async (3)
- # defnpodcast (1)
- # deps-new (8)
- # events (3)
- # graalvm (10)
- # graphql (4)
- # gratitude (2)
- # hyperfiddle (7)
- # introduce-yourself (4)
- # jobs (1)
- # membrane (9)
- # pedestal (5)
- # quil (2)
- # re-frame (7)
- # releases (2)
- # rewrite-clj (14)
- # shadow-cljs (8)
- # tools-deps (5)
Is there a Membrane way to do a popup/take UI focus from the desktop background? I've made a global keypress handler (via JNativeInput), but I need to bring my program to the forefront of the desktop.
In the CljFx/Java2D code, I use (.requestFocus node)
on an https://githubhot.com/repo/cljfx/cljfx/issues/94 & just toggle the visibility on/off.
I note that (.setVisible (:membrane.java2d/frame x) false)
works to change visibility using the Swing API. I think I can get this working if I wrap Swing & https://www.b4x.com/android/forum/threads/solved-how-to-set-the-focus-to-a-non-java-application-in-windows.99253/#post-624929, but would anyone recommend a different approach?
That approach sounds reasonable to me. For Swing, this stackoverflow answer also looks like you might be able to avoid OS specific code, https://stackoverflow.com/a/64220284. I haven't tried it though.
I'll take a look, nice to avoid OS custom impls. Is stuff like supporting toplevel "visibility" in-scope for Membrane to eventually support, or is this fundamentally not something the library should tackle? (I think the idea is excellent & might be able to add some PRs eventually)
Yea, that sounds great! If there's a way to abstract it across backends, we can make a common API. If there's not, it's totally fine to just have implementations that support individual backends/OS's
Good to know! If I can get my app off the ground then I'll need to support multiple platforms, so I'll be thinking about how to PR this as I code. Thanks for the advice & hope you're having a good weekend 👋☀️
I had a repl open, so I just tried out the stackoverflow code. Seems to work on Mac OSX
(ns focus
(:require [membrane.java2d :as backend]
[membrane.ui :as ui]))
(def window-info (backend/run #(ui/label "ui")))
(def frame (::backend/frame window-info))
;; manually minimize or send window to bottom
;; bring window to front
(javax.swing.SwingUtilities/invokeLater
(fn []
(.requestFocusInWindow frame)
(.setVisible frame true)))
Also, thanks for trying membrane. I would love to hear your feedback (including the good, bad, or ugly).
I'm just getting into Membrane. So far, I find the stricter decoupling of the events & UI makes the code easier to grok than CljFx. While there's less references to Google, I'm used to diving into library code & am interested in leveraging the benefits (hierarchical UI composability, multiplatform views)