clj-ns-browser icon indicating copy to clipboard operation
clj-ns-browser copied to clipboard

"Sorry... cannot close/hide last browser window."

Open ivan opened this issue 12 years ago • 8 comments

On Windows 7, JDK 1.7.0_07 64-bit, closing clj-ns-browser's main window by clicking the [X] button on the window (or Alt-F4) always results in a message dialog that says:

"Sorry... cannot close/hide the last browser window."

ivan avatar Sep 13 '12 10:09 ivan

The only way I can quit it is by pressing ctrl-c in the command prompt.

ivan avatar Sep 13 '12 10:09 ivan

This is a known issue/feature…

The problem is that the menus are associated with a window in swing, so if there is no window becaause you closed it, then there is no way to leave a menu bar where you could get a new window.

My "solution" is to always leave one window there, and that last window cannot be closed.

I realize that either way is confusing for the user… I'm eagerly awaiting for suggestions for a better solution (?).

The only pargmatic remedy I can suggest is that if you're bothered by that last browser window, you can always minimize it such that it gets out of the way.

On Sep 13, 2012, at 3:55 AM, Ivan Kozik [email protected] wrote:

The only way I can quit it is by pressing ctrl-c in the command prompt.

— Reply to this email directly or view it on GitHub.

franks42 avatar Sep 13 '12 16:09 franks42

I'm a little confused. If I start clj-ns-browser with lein run or -m clj-ns-browser.core and then close the last window, isn't that a good indication that I'm done with clj-ns-browser and don't need any more windows? I can always run it again if I need it. I'm guessing I can even leave the JVM running and not pay most of the startup cost again.

Is there a popular use case I'm missing?

ivan avatar Sep 13 '12 17:09 ivan

Bringing up the browser stand-alone is a great way to use it, but you're missing my most common use case where I run clj-ns-browser inside of another app during development, starting a repl, bringing up the browser with (sdoc …) when I need it, browse thru the libs and look at examples/values with 1 or more browser windows, discard windows (i.e. minimize the last one), go on with coding until I want to browse more, (recur to-sdoc)…

In the latter case you definitely do not want to bring the jvm down when you close the last browser window.

On Sep 13, 2012, at 10:44 AM, Ivan Kozik [email protected] wrote:

I'm a little confused. If I start clj-ns-browser with lein run or -m clj-ns-browser.core and then close the last window, isn't that a good indication that I'm done with clj-ns-browser and don't need any more windows? I can always run it again if I need it. I'm guessing I can even leave the JVM running and not pay most of the startup cost again.

Is there a popular use case I'm missing?

— Reply to this email directly or view it on GitHub.

franks42 avatar Sep 13 '12 18:09 franks42

I think what Ivan was suggesting was that if it was possible to do (sdoc) to bring up a first browser window, and then close it if he thought he didn't need it any more but that JVM continued running, and then later he decided he did want a browser window again, just issue (sdoc) from the REPL again. I don't recall whether there are difficulties with implementing that behavior. Do you, Frank?

jafingerhut avatar Sep 13 '12 18:09 jafingerhut

There is no problem changing the code such that the last browser window will truly close, but then you will be left with a menu bar without any File/Edit/etc. menus because they are tied to the app's window. A useless, confusing menu bar that doesn't allow you to bring-up a new browser window. (sdoc) from the repl would bring up a new browser, though.

Closing the Swing part of the app, which would get rid of the menu bar also, is difficult, because our browser may be embedded in another swing-based app and you do not want to affect that.

My chosen alternative was to leave the last browser-window up and prevent it from being closed. Still not ideal, but at least you can minimize it to get it out of the way. Even when minimized, the app will still show a useful menubar.(sdoc) from the repl will bring up the last browser back in view if it's minimized.

One visual improvement may be to cheat a little and minimize the last window when the user tries to close it.

Seesaw's Dave suggested to maybe use an invisible, off-screen window that would never be closed and would provide you with a useful browser's menubar.

I realize that none of the approaches is "ideal"…

On Sep 13, 2012, at 11:25 AM, Andy Fingerhut [email protected] wrote:

I think what Ivan was suggesting was that if it was possible to do (sdoc) to bring up a first browser window, and then close it if he thought he didn't need it any more but that JVM continued running, and then later he decided he did want a browser window again, just issue (sdoc) from the REPL again. I don't recall whether there are difficulties with implementing that behavior. Do you, Frank?

— Reply to this email directly or view it on GitHub.

franks42 avatar Sep 14 '12 18:09 franks42

I don't get it :)

ghost avatar Mar 03 '13 10:03 ghost

In short, the best solution is to use an invisible, off-screen window that would never be closed, which would be able to show the browser's menubar.

However, that requires coding... and I don't see it as a high priority as you can minimize the window if it gets in the way.

I'd be happy to pull-in a patch that would resolve this issue though...

franks42 avatar Mar 05 '13 06:03 franks42