ztellman / penumbra

not under active development - idiomatic opengl bindings for clojure
354 stars 43 forks source link

Setting the window title caption (and manipulating the Frame in general) #5

Closed elliottslaughter closed 15 years ago

elliottslaughter commented 15 years ago

Hi,

I'm wondering if you've intended there to be any way for users of window.clj to manipulate the top-level Frame, for example to call setTitle. If not, then I'd like to request that this be added. It might also be nice to be able to provide the title parameter to the Frame constructor.

Thanks.

ztellman commented 15 years ago

http://gist.github.com/188865

elliottslaughter commented 15 years ago

On Mac OS X, there are actually two window captions: one in the menu bar for the window, and one in the frame itself. Your set-title method changes the frame but not the window (it still displays "clojure.lang.Repl"). Is there any way set-title can change both, or change them individually?

Thanks.

ztellman commented 15 years ago

You can call (get-frame) from anywhere inside the window callbacks to get the Frame object. I don't know what the proper function call is, but if you find it, let me know.

elliottslaughter commented 15 years ago

Apparently the menu bar is controlled through system properties. So one way to change the menu title is

(System/setProperty "com.apple.mrj.application.apple.menu.about.name"
                    "My Application Title")

The strange thing is, you need to call this before the Frame is created (it doesn't seem to affect the menu retroactively). For penumbra, that means I've added the code before the (use 'penumbra.opengl) line.

Another way to change the title is to pass java the following option.

-Xdock:name="My Application Title"

Both of the above work for me, although they aren't really very convenient, and don't provide a general solution to the problem (from the perspective of providing this capability from penumbra).

The third way I've read about (but haven't tried) is to create an app for the program and set some field in the property list. See http://stackoverflow.com/questions/307024/native-swing-menu-bar-support-for-macos-x-in-java for more information.

Hope this helps.

ztellman commented 15 years ago

Hmm, I guess I could add it as an optional parameter to window/start.

I'll look at it further this weekend.