I figured out that problem too, but I don’t know whether this is window 
specific or not.
Sure I think you can add a shortcut to your Code, which is already taken. You 
got a warning after NetBeans started that says: „there is a duplicate“.
Maybe it overrides it or not, I don’t know atm. But if not and you created an 
Action, where you can Change the shortcut via KeyMap Options, you sometimes 
overrides existing ones (Which Shows you a warning or error that another one 
has the same etc.), but yes they should work context sensitve, and some are 
still working context sensitive, afaik.

I set ctrl + b to Show the git browser for branches etc. This shortcut only 
Woks, when I select a Project. If I’m in the Editor, it will set a bookmark or 
open the bookmark window. So there is smth like a context sensitive way to 
implement shortcuts but I don’t know the logic at all.

My 2 cents


Cheers

Chris

Von: Tim Boudreau
Gesendet: Montag, 26. Februar 2018 19:59
An: dev@netbeans.incubator.apache.org
Betreff: Re: Platform API: Context-sensitive keyboard accelerators

It's been a long time since I worked on the code involved, so my
recollection may be a little fuzzy, but this may help point you in a
direction or two:

There is a general problem that NetBeans supports, or at least used to
support, both single window pseudo-SDI mode and a multiple windows mode.
And keyboard shortcuts propagate down to the InputMap/KeyMap of the window
in question.  My recollection is that this was originally handled with an
AWTEventListener, because that was the one way to guarantee shortcuts
worked globally, no matter the windowing layout.  I *think* we migrated
that to something using InputMap/KeyMap around 2003 or so, but there may
still be workarounds to ensure things work globally.

What I'd suggest to try is an experiment - create a dialog with the dialogs
API and try binding a key you know is bound as a global shortcut.  Use
InputMap/KeyMap and attach it to, most likely, the root pane of the dialog.

If it works, then it's just a matter of implementing shortcuts in the right
places (make sure to call consume() on the event to stop it propagating
further).  If it doesn't, then some more fundamental work that's likely to
touch how key bindings work globally may be needed.

Also bear in mind that key bindings are different for different platforms -
on Mac OS, the alt key is a compose key for international characters and
cannot have shortcuts bound to it (ctrl is used instead), and some
keybindings are mapped to different keys for consistency with other Mac OS
apps (there's a syntax for defining keybindings in OS-neutral ways, for
declarative bindings).

HTH,

Tim


On Mon, Feb 26, 2018 at 9:11 AM, cowwoc <cow...@bbs.darktech.org> wrote:

> Hi,
>
> Netbeans has an extremely long (and getting longer) list of keyboard
> shortcuts. Part of the problem is that (for the most part) keyboard
> shortcuts are not context-sensitive nor are they able to be
> context-sensitive. I'll give you a simple example I raised a few years back:
>
> When the editor Find & Replace dialog is focused, we have "Replace" and
> "Replace All" buttons. It would be nice if we could map ALT+A to "Replace
> All" as many other applications do. Unfortunately, ALT+A is already mapped
> to the Refactor pulldown menu. The platform API does not allow mapping the
> same keyboard accelerator to different UI actions depending on the context.
> As a result, we end up with akward combinations like ALT+P for Replace All.
>
> Please see https://netbeans.org/bugzilla/show_bug.cgi?id=222843 for
> additional context.
>
> Is anyone else interested in this issue? Is anyone interested in working
> on it?
>
> Thank you,
> Gili
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscr...@netbeans.incubator.apache.org
> For additional commands, e-mail: dev-h...@netbeans.incubator.apache.org
>
> For further information about the NetBeans mailing lists, visit:
> https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
>
>
>
>


-- 
http://timboudreau.com

Reply via email to