Don't deselect when bringing window into focus via click

Issue #232 on hold
Robert Leach created an issue

I think that deselecting via a click on nothing is a reasonable feature, but I don't think it should happen when the app does not have focus. E.g. you switch to your web browser or your email app and then you click on a portion of the treeview app window to bring it forward. In instances like that, I don't think that a deselection should happen.

Comments (14)

  1. Christopher Keil repo owner

    Should be a decently easy fix. There only needs to be a hasFocus() check for the appropriate JComponent. I'll take it up.

  2. Robert Leach reporter

    Incidentally, I think basically nothing should happen when the window is not in focus unless they hold down the command key. I frequently interact with windows that are not in focus by holding down the command key. Here's how I would describe what happens in other apps when clicking on an app/window that is behind another window:

    Action: left-click on a window that is not in focus Result: window comes into focus and nothing changes in the app (nothing is selected/deselected, buttons are not pressed, etc - the only thing that happens is the window comes into focus)

    Action: command-left-click on a window that is not in focus Result 1: The window remains not in focus Result 2: the interface behaves as it would if there was a regular left-click (no command key down) (Non-)Result 3: any action that is triggered via a command-click in the app simply is not possible when the window is not in focus

    Action: command-otherOptionalModifier-(left/right)-click-(optionalHold) Result 1: The window remains not in focus Result 2: the interface behaves as it would if there was a custom-click (but with no command key down)

  3. Christopher Keil repo owner

    As far as I can tell the CMD + Out-of-focus action is absolutely non-trivial short of implementing this in C.

    Java does not allow OS-level programming for the most part. You may not decide via Java if a window is pulled in focus or not. That's the job of the OS. This means that if you click on the Window even with held-down CMD it WILL become active. The reason for this is security as cited by Java documentation as well as Java being multi-platform.

    I still resolved the original issue. When the window is not active (in background) the selection won't be affected when clicking the window.

  4. Robert Leach reporter

    Actually, command-clicking a non-focussed window in Mac OS X does not bring it into focus. I just tested it. As you said, the OS handles whether or not a window comes into focus. All treeview has to do is know whether or not it is in focus and in the context - how to treat the command-click. So it seems doable.

  5. Robert Leach reporter

    Not sure how Linux or Windows implements this behavior for its apps. Does windows even have a way to interact with an unfocussed window? It's been around for Macs for as long as I can remember.

  6. Christopher Keil repo owner
    • changed status to open

    Opening this again. I will try to implement the CMD+Unfocused behavior for OSX. This isn't usual behavior for Windows or Linux as far as I can tell (after some trial & search) but if it is native OSX the Mac-specific inclusion should be worth it.

  7. Log in to comment