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 47305 - I18N - Unable to enter some national (polish) characters
Summary: I18N - Unable to enter some national (polish) characters
Status: CLOSED FIXED
Alias: None
Product: editor
Classification: Unclassified
Component: -- Other -- (show other bugs)
Version: 4.x
Hardware: PC Windows XP
: P3 blocker (vote)
Assignee: Miloslav Metelka
URL:
Keywords: I18N
Depends on:
Blocks:
 
Reported: 2004-08-17 11:42 UTC by cezariusz
Modified: 2015-03-27 07:40 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description cezariusz 2004-08-17 11:42:58 UTC
>System Info: 
  Product Version       = NetBeans IDE Dev 
(Build 200408161800)
  Operating System      = Windows XP version 5.1 
running on x86
  Java; VM; Vendor      = 1.5.0-beta2; Java 
HotSpot(TM) Client VM 1.5.0-beta2-b51; Sun 
Microsystems Inc.
  Java Home             = C:\Program 
Files\Java\jdk1.5.0\jre
  System Locale; Encod. = pl_PL (nb); Cp1250


To enter polish character "¹" I have to 
press "a" while holding "Alt Gr" pressed. When I 
do this whole section of text is replaced 
with "¹" instead of just inserting the letter.

The reason probably is that "Alt Gr" is an 
equivalent of right Alt+Ctrl, and Alt+Ctrl+a 
does some kind of section select, which is 
immediately replaced by character "¹".

Here's how it should work:
- pressing AltGr+a should insert "¹" - it should 
call Alt+Ctrl+a shortcut
- pressing left Alt+Ctrl+a should:
  * call the shortcut Alt+Ctrl+a
  * insert "¹" if there is NO shortcut Alt+Ctrl+a
This is the way Microsoft Office works.

To reproduce: install and activate "polish 
programmer" keyboard layout.
Comment 1 psuk 2004-08-17 12:26:45 UTC
Adding I18N keyword
Comment 2 cezariusz 2004-08-17 13:06:18 UTC
Using
http://java.sun.com/docs/books/tutorialJWS/uiswing/events/example-
1dot4/KeyEventDemo.jnlp
I checked the codes of keys, here's the result of pressing and 
immediate releasing of:

LEFT CONTROL
============
KEY PRESSED: 
    key code = 17 (Ctrl)
    modifiers = 128 (Ctrl)
    action key? NO
    key location: left
KEY RELEASED: 
    key code = 17 (Ctrl)
    modifiers = 0 (no modifiers)
    action key? NO
    key location: left

LEFT ALT
========
KEY PRESSED: 
    key code = 18 (Alt)
    modifiers = 512 (Alt)
    action key? NO
    key location: left
KEY RELEASED: 
    key code = 18 (Alt)
    modifiers = 0 (no modifiers)
    action key? NO
    key location: left

ALT GR
=======
KEY PRESSED: 
    key code = 17 (Ctrl)
    modifiers = 128 (Ctrl)
    action key? NO
    key location: left
KEY PRESSED: 
    key code = 18 (Alt)
    modifiers = 640 (Ctrl+Alt)
    action key? NO
    key location: right
KEY RELEASED: 
    key code = 17 (Ctrl)
    modifiers = 512 (Alt)
    action key? NO
    key location: left
KEY RELEASED: 
    key code = 18 (Alt)
    modifiers = 0 (no modifiers)
    action key? NO
    key location: right

LEFT CTRL + LEFT ALT + A
========================
KEY PRESSED: 
    key code = 17 (Ctrl)
    modifiers = 128 (Ctrl)
    action key? NO
    key location: left
KEY PRESSED: 
    key code = 18 (Alt)
    modifiers = 640 (Ctrl+Alt)
    action key? NO
    key location: left
KEY PRESSED: 
    key code = 65 (A)
    modifiers = 640 (Ctrl+Alt)
    action key? NO
    key location: standard
KEY TYPED: 
    key character = '¹'
    modifiers = 8192 (Alt Graph)
    action key? NO
    key location: unknown
KEY RELEASED: 
    key code = 65 (A)
    modifiers = 640 (Ctrl+Alt)
    action key? NO
    key location: standard
KEY RELEASED: 
    key code = 18 (Alt)
    modifiers = 128 (Ctrl)
    action key? NO
    key location: left
KEY RELEASED: 
    key code = 17 (Ctrl)
    modifiers = 0 (no modifiers)
    action key? NO
    key location: left

ALT GR + A
==========
KEY PRESSED: 
    key code = 17 (Ctrl)
    modifiers = 128 (Ctrl)
    action key? NO
    key location: left
KEY PRESSED: 
    key code = 18 (Alt)
    modifiers = 640 (Ctrl+Alt)
    action key? NO
    key location: right
KEY PRESSED: 
    key code = 65 (A)
    modifiers = 640 (Ctrl+Alt)
    action key? NO
    key location: standard
KEY TYPED: 
    key character = '¹'
    modifiers = 8192 (Alt Graph)
    action key? NO
    key location: unknown
KEY RELEASED: 
    key code = 65 (A)
    modifiers = 640 (Ctrl+Alt)
    action key? NO
    key location: standard
KEY RELEASED: 
    key code = 17 (Ctrl)
    modifiers = 512 (Alt)
    action key? NO
    key location: left
KEY RELEASED: 
    key code = 18 (Alt)
    modifiers = 0 (no modifiers)
    action key? NO
    key location: right

Hope it helps.
Comment 3 Miloslav Metelka 2004-08-18 14:53:23 UTC
The problem is that the java is unable to distinguish between the
Ctrl+Alt+A and AltGr+A. As we have an "Select Next Element" action
mapped to Ctrl+Alt+A it will get invoked on the key_pressed event.
After that there comes the key_typed which inserts the special char.
To get it work properly the only way I see is to unmap the Ctrl+Alt+A
binding or remap it to something else.
You can unmap the Ctrl+Alt+A in Tools->Options->Editing->Editor
Settings->Java Editor->Key Bindings search for "Select Next Element"
action, click on the key binding and remove it.
Comment 4 cezariusz 2004-08-18 15:38:43 UTC
What about adding an option, saying that right Alt shouldn't be used 
for shortcuts?
It's not only about Alt+Ctrl+a, but also in some button shortcuts. 
For example in Auto comment dialog, I cannot enter letter "³", 
because it inserts "{@link }".
Comment 5 Miloslav Metelka 2004-08-18 15:58:28 UTC
I think the jvm is unable to distinguish between left and right alt so
the only permanent solution would be to use *no* Ctrl+Alt+<key>
shortcuts throughout the whole IDE. This is possible although right
now we are short of the available shortcuts anyway so this would make
the situation even worse. Passing to ui module for evaluation whether
this would be doable.
Comment 6 cezariusz 2004-08-18 17:07:09 UTC
Why do you say jvm is unable to distinguish between left and right 
alt? Look at my comment #2, the output from java sample says:

LEFT ALT
========
KEY PRESSED: 
    key code = 18 (Alt)
    key location: left
                  ^^^^

ALT GR
=======
KEY PRESSED: 
    key code = 18 (Alt)
    key location: right
                  ^^^^^
Comment 7 Miloslav Metelka 2004-08-19 14:06:57 UTC
Yes I did not say it right as I was looking mainly to the produced
key_typed events that cause the document insertions. They seem to be
the same in both cases:

LEFT CTRL + LEFT ALT + A
========================
KEY TYPED: 
    key character = '¹'
    modifiers = 8192 (Alt Graph)
    action key? NO
    key location: unknown

ALT GR + A
==========
KEY TYPED: 
    key character = '¹'
    modifiers = 8192 (Alt Graph)
    action key? NO
    key location: unknown

In theory it would be possible to eliminate the key_typed events in
specific conditions i.e. eliminate the key_typed that came after the
key_pressed with right alt pressed. We did those kinds of patches in
the past to overcome various JDK keyboard related flaws. The problem
is that the patches usually do not work well across platforms and
various keyboard layouts - please see e.g. the issue 44307.
Comment 8 David Simonek 2004-08-19 15:38:02 UTC
Milo, I have to return this issue back to you, because I don't
understand what your request actually is and how could core solve
that. I understand the original problem, but I don't understand role
of core in this. Is core blocking you to differentiate between left
and right Alt or what?
Comment 9 cezariusz 2004-08-19 16:20:49 UTC
> In theory it would be possible to eliminate the key_typed
> events in specific conditions i.e. eliminate the key_typed
> that came after the key_pressed with right alt pressed.

Because of possible compatibility problems I suggest to add an 
option to simply ignore right Alt in shortcuts (do not execute any 
shortcut if right alt is pressed).
For US keyboards the option will be off by default, so it will 
change nothing. For other layouts users will turn it on, so that 
right alt will be used only for special characters (alt graph), and 
let alt only for shortcuts. Note that when left alt is used, editor 
should eat the KEY TYPED "¹" event not to overwrite block selected 
with the shortcut.
Comment 10 Miloslav Metelka 2004-08-19 17:56:37 UTC
Apologies, Dafe, originally I was transfering to ui/ui hoping that the
UI people will comment on the proposal to eliminate Ctrl+Alt+<key>
shortcuts from being used for the IDE shortcuts completely.
 Actually there should not be many of those - I've found just two by
scanning the main window menu under Tools->JUnit Tests - Ctrl+Alt+J
and Ctrl+Alt+K and there are few used in the editor.
I've put ui issues on cc.
Comment 11 cezariusz 2004-08-19 17:59:41 UTC
Note that it also affects buttons in some dialogs, like in auto 
comment dialog.
Comment 12 Miloslav Metelka 2004-08-19 19:34:53 UTC
To Cezariusz:
As I've already mentioned the keyboard patching (eating key_typed
etc.) is a thin ice so I would prefer other solution if possible.

> For other layouts users will turn it on
IMHO just few people would find the option as hardly anyone would
expect that such configurable option would be present in the IDE.
Turning it on automatically would IMHO not be easy either as I'm not
aware of how to find out the current keyboard layout in java
programatically.

I'll talk to our UI people regarding this issue.
Comment 13 _ tboudreau 2004-09-04 22:27:08 UTC
Similar issue I just helped someone out with on the Apple java 
mailing list - Alt-Shift-8 (winsys defined) is the way to do a { 
character.

We may want to think hard about some system that works better for 
both per-locale and per-platform bindings.
Comment 14 cezariusz 2004-09-21 10:09:39 UTC
------- Additional Comments From Miloslav Metelka 2004-08-19 11:34 PDT
-------
> I'll talk to our UI people regarding this issue.

Any conclusions?
Comment 15 Miloslav Metelka 2004-10-06 10:30:33 UTC
I have entered issue #49945 and fixed it today which should eliminate
this problem.
Comment 16 cezariusz 2006-06-13 10:37:10 UTC
Verified in 200606120200.