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 225172 - Mapping numeric keys like SUBTRACT to actions will perform action AND insert the '-' character
Summary: Mapping numeric keys like SUBTRACT to actions will perform action AND insert ...
Status: NEW
Alias: None
Product: platform
Classification: Unclassified
Component: Text (show other bugs)
Version: 7.3.1
Hardware: PC All
: P3 normal (vote)
Assignee: Miloslav Metelka
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-01-22 09:30 UTC by JoeyJoJo
Modified: 2013-03-25 09:35 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Possible fix (5.62 KB, patch)
2013-03-20 15:17 UTC, Svata Dedic
Details | Diff
Cleaned up possible fix (3.05 KB, patch)
2013-03-20 15:57 UTC, Svata Dedic
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description JoeyJoJo 2013-01-22 09:30:27 UTC

    
Comment 1 JoeyJoJo 2013-01-22 09:36:37 UTC
It seems to be a general thing for keys that have an associated printable character. If a a printable key is mapped to an action and the key is pressed the action will be performed first followed by the insertion of the printable character into the text document.

It may be considered counter-intuitive to map printable characters to actions (e.g. mapping of close file to 'x')... but the use case here is to map cut to SUBTRACT, copy to ADD and paste to NUMPAD0.

It just seems annoying that it is not possible to do so with the current convention of always printing printable characters when pressed.
Comment 2 Svata Dedic 2013-03-20 14:17:46 UTC
Not specific to Windows, reproduced on Ubuntu Linux, too.
Comment 3 Svata Dedic 2013-03-20 15:16:30 UTC
I suppose it is a de-facto standard behaviour; or better that mapping to a character keys without modifiers was not considered at all. 

What happens is that a KEY_PRESSED event arrives and is translated to the desired action. Then a KEY_TYPED arrives, which inserts the character into the document. 

It could be worked around in the QuietEditorPane (Text API) - see the attached patch. However I am not 100% sure whether the fix has no side effects, so reassigning to the component's owner.
Comment 4 Svata Dedic 2013-03-20 15:17:17 UTC
Created attachment 132851 [details]
Possible fix

Milo - please review the patch
Comment 5 Svata Dedic 2013-03-20 15:57:27 UTC
Created attachment 132856 [details]
Cleaned up possible fix

Please disregard the original attachment; some unrelated diagnostics leaked in.
Comment 6 Miloslav Metelka 2013-03-25 09:35:39 UTC
Patching just QuietEditorPane would not affect cases when a regular JEditorPane with NbEditorKit is located in a dialog (e.g. Evaluate expression in debugger etc.).

In past JDKs (IIRC 1.2 till 1.4) we were sometimes forced to consume KEY_TYPED events since they were sometimes sent even in cases when they shouldn't be so we've established a handling for that in o.n.editor.MultiKeymap - there's still a flag for running in compatible mode:

-J-Dnetbeans.editor.keymap.compatible=true

Could you run NB with that flag turned on whether it helps you with the SUBTRACT key? Thanks.