This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 61029 - Implement multi key binding infrastructure
Summary: Implement multi key binding infrastructure
Status: RESOLVED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Window System (show other bugs)
Version: 5.x
Hardware: All All
: P3 blocker (vote)
Assignee: apireviews
URL:
Keywords: API, API_REVIEW_FAST
Depends on: 61927 61928
Blocks:
  Show dependency tree
 
Reported: 2005-07-15 13:21 UTC by Petr Nejedly
Modified: 2008-12-22 23:00 UTC (History)
2 users (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments
Proof of concept implementation (8.21 KB, patch)
2005-07-15 13:23 UTC, Petr Nejedly
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Petr Nejedly 2005-07-15 13:21:03 UTC
We need a way to register and handle binding of action to a sequence of keystrokes.

I'm proposing enhancing the way we currently register bindings.
Currently core processes instance files in the Shortcuts layer folder. The files
represent instances of actions, while their names represent the keystroke to
bind the action to ("C-A" means Ctrl+A).

The proposal is to handle also subfolders in the Shortcuts folder, where the
name of the subfolder is the prefix of the keysequence and the files/subfolders
under the subfolder represent actions/prefixes bound to the prefix and the last
keystroke. E.g. for
<file name="Shortcuts/C-E/C-J.instance"><attr ... "MyAction"/></file>, MyAction
will be invoked after pressing Ctrl+E Ctrl+J 

I'll attach a prototype implementation that both understands proposed
registration of multikeybindings and handles keyboard input according to
registrations. It also properly handle changes on the SFS to allow
customizations, but the customizer is not reimplemented.

The only changed exported interface is the layer registration format.
Comment 1 Petr Nejedly 2005-07-15 13:23:05 UTC
Created attachment 23120 [details]
Proof of concept implementation
Comment 2 Petr Nejedly 2005-07-15 13:26:01 UTC
Notes:
*) There are no tests so far. A test would consist of a layer registration and
  then a walk through the keymap (get action for keystroke, invoke it, verify
  right action was invoked)

*) The implementation could be simplified by merging common code in both
ShortcutsFolder and NbKeymap
Comment 3 Jaroslav Tulach 2005-07-15 14:26:27 UTC
I am not sure what will happen if there is "three keystroke shortcut". Imho 
the algorithm will get broken. My guess: Instead of search for global map, you 
more likely want a Keymap to be associated with each ShortcutsFolder instance 
and register there. 
Comment 4 Petr Nejedly 2005-07-15 16:07:56 UTC
> I am not sure what will happen if there is "three keystroke shortcut".

It will just work. Why it shouldn't?
The context shift actions will get executed one after another, each from its own
context (which is irrelevant) and each will finally set the next context.

I don't understand the "My guess" section, but for each subfolder, there will be
a single instance of ShortcutsFolder$SubFolder, single instance of
NbKeymap$SubKeymap and a single instance of NbKeymap$KeymapAction.
The actual context is held only inside the root Keymap, as it is the only one
visible to the components.

And yes, I've just tried binding SystemExitAction to C-E/C-R/C-T and it worked
correctly ("C-E, whatever" eats the "whatever" keystroke, "C-E, C-R, whatever"
ditto, "C-E, C-R, C-T" will perform the right action).
You can easily test it yourself by creating folders and .instance files in your
userdir (don't forget the .nbattrs next to .instance to provide instanceClass attr).
Comment 5 Petr Nejedly 2005-08-04 13:38:33 UTC
Integrated.
Comment 6 Jaroslav Tulach 2005-08-08 13:14:24 UTC
After discussion with pnejedly, we realize that the best way to express that 
the work is not complete is to remind us of issue 61927 and issue 61928.