Bug 39074 - [CellEditors] [DBCS] canna input mode fires bogus event from Text Control
Summary: [CellEditors] [DBCS] canna input mode fires bogus event from Text Control
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 2.1   Edit
Hardware: PC Linux-GTK
: P2 critical (vote)
Target Milestone: 2.1.3   Edit
Assignee: Nick Edgar CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 39018 (view as bug list)
Depends on:
Blocks: 44387
  Show dependency tree
 
Reported: 2003-06-18 11:38 EDT by Randy Hudson CLA
Modified: 2004-03-11 21:46 EST (History)
11 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Randy Hudson CLA 2003-06-18 11:38:29 EDT
Steps:
1)Create simple file named foo.usr.
2)Open the propertysheet example editor on this file.
3)Select a department (or group or whatever) and go to edit the name of that 
object in the propertysheet
4) Shift+SPACE to enter canno input mode.
5) Type "nihongo" and press ENTER

When you press ENTER, the propertysheet receives either a bogus 
widgetDefaultSelected event, or a bogus focusLost event.  In either case, the 
entered canna text is lost.

This affects anyone who displays a popup celleditor and is interested in the 
events mentioned above.  This bug affects multiple GEF clients in WSAD
Comment 1 Randy Hudson CLA 2003-06-18 11:39:25 EDT
*** Bug 39018 has been marked as a duplicate of this bug. ***
Comment 2 Felipe Heidrich CLA 2003-06-18 12:18:16 EDT
How can I get this "propertysheet example editor" ?
Is this part of Eclipse ?
Comment 3 Randy Hudson CLA 2003-06-18 13:09:45 EDT
Yes, it is part of the Eclipse Examples
Comment 4 Randy Hudson CLA 2003-06-18 13:11:16 EDT
I do not have access to GTK machine, otherwise I would provide the test snippet.

Instead of downloading examples, why not start with a Shell and a Text Control, 
and add a focusLost and widgetDefaultSelected listener to the Text control.  
Neither event should be fired when the canna characters are committed.
Comment 5 Jon Corchis CLA 2003-06-18 13:53:38 EDT
Did anyone try another input server?
Comment 6 Felipe Heidrich CLA 2003-06-18 18:58:22 EDT
I don't think using a different conversion server would help, maybe other input 
method than kinput2  can behave differently. (note, I assuming that you guys 
are using kinput2).

I'm not completely sure that the focus out and the selection events are 
bogus... maybe it is just what happens. When entering Japanese input the user 
can use space space to invoke the candidate conversion window. In this case the 
text widget actually lost the focus for the candidate window. Once the input is 
commit the focus returns to the widget what can be causing the selection event 
you refer.

I know that in your step you don't talk about using the candidate window but I 
just saying the lost focus event might occur.

I'll look at this problem.

Comment 7 Randy Hudson CLA 2003-06-18 19:46:35 EDT
widget *default* selected is different than just the caret being positioned 
(widget selected).
Comment 8 Masaki Wakao CLA 2003-06-19 08:34:20 EDT
The problem is not with candidate window.
The problem is TextCellEditor's behavior with Japaense input.
You should try PropertiesView example or any TextCellEditor on workbench.



The following code in TextCellEditor#createControl() may be 
a hint to fix this problem.

-------------------------------------------------------
	text.addKeyListener(new KeyAdapter() {
		// hook key pressed - see PR 14201  
		public void keyPressed(KeyEvent e) {
---->			keyReleaseOccured(e);
-------------------------------------------------------

I think defaultWidgetSelected() should be used instead of 
handling KeyPressed event for enter-key directly. 

So how about the following code ?
-------------------------------------------------------
	text.addSelectionListener(new SelectionListener() {
		public void widgetSelected(SelectionEvent e) {}
		public void widgetDefaultSelected(SelectionEvent e) {
			// same with enter-key handling code in keyReleaseOccured(e);
			fireApplyEditorValue();
			deactivate();
		}	
	});
	text.addKeyListener(new KeyAdapter() {
		// hook key pressed - see PR 14201  
		public void keyPressed(KeyEvent e) {
			//keyReleaseOccured(e);
-------------------------------------------------------
ESC key handling also needed.



Actually, key press event should not be sent to application 
if the key event is used by IM.
But current implementation of GTK's Text widget seems not to do so.
I have not looked into GTK, but currentlly, I think it is a problem of GTK2. 
The above code is a kind of workaround of it. 
Comment 9 Randy Hudson CLA 2003-06-19 09:08:52 EDT
Yes, that is workaround. I think we all agree the meaning of ENTER was to 
commit the DBCS characters, therefore the text control should not receive the 
event.

I'm suprised CellEditor was written this way.  I wonder why 
widgetDefaultSelected was not used initially?
Comment 10 Felipe Heidrich CLA 2003-06-19 12:47:42 EDT
Randy, I did what you said: simple test with a Shell and a Text, I hooked 
Modify, FocusOut, Selection, DefaultSelection. I don't see the bogus events you 
are talking about.
I noticed that the enter key is always filtered when in japanese mode (gtk 
filtered). But you still get DefaultSelection events.

We have changed this part of the code a week ago, I advise you guys to use the 
latest SWT code for testing.

I still didn't find the property sheet editor example... 
Comment 11 Randy Hudson CLA 2003-06-19 14:13:07 EDT
Click on any eclipse downloads page and scroll down to "Example Plug-ins".
As I mentioned before, you must create the file "xxx.usr", there is no wizard 
or any other indication that the propertysheet plugin exists.

What is the bugzilla corresponding to the changed 2.1.1 code a week ago?
Comment 12 Felipe Heidrich CLA 2003-06-19 16:35:42 EDT
It works fine for me on HEAD.
Test with GTK 2.2.1 and GTK 2.2.2, running on SuSE 8.2, locale ja_JP

Which Linux and GTK version are you guys running ?
Comment 13 Felipe Heidrich CLA 2003-06-19 16:40:51 EDT
Actually, which version of eclipse are you guys running ? eclipse 2.1.1 or
eclipse 2.1 >.
Comment 14 Felipe Heidrich CLA 2003-06-19 16:49:25 EDT
"What is the bugzilla corresponding to the changed 2.1.1 code a week ago?"

what changed ? the one I mention on comment 11 (this one is related with 
filtering keys and was only released on HEAD) -or- the fix for bug 38388 (see 
the swt build notes)
Comment 15 Randy Hudson CLA 2003-06-19 17:50:32 EDT
We were using GTK 2.2.0, and 2.1.1 that might be as old as 2 weeks, but not 
older.

Cam, can you have Hwa download the latest 2.1.1 Eclipse and find me on Friday 
to confirm?
Comment 16 Felipe Heidrich CLA 2003-06-19 18:42:35 EDT
It fails on 2.1.1 but works on HEAD cause of the changes for filtering key.

The problem is that the application is receiving the Enter key before OS and try
to get the text of the widget, but at this moment the text is still on the
preedit buffer (it will only be committed to widget after the OS sees the Enter
Key).

It works when the DefaultSelection event is used (instead of testing for the
Enter key during the KeyPress) because the DefaultSelection happens after the
OS. This is the workaround for this problem.
 

Comment 17 Randy Hudson CLA 2003-06-19 20:55:28 EDT
Are you saying that defaultSelected is not fired, or just that it is fired 
after the OS widget receives the characters?  The correct behavior is for 
defaultSelected *not* to fire. The user should be able to alternate between 
DBCS and normal entry without the CellEditor closing.  If defaultSelected is 
being fired, the cell editor will be closed prematurely.
Comment 18 Felipe Heidrich CLA 2003-06-20 15:42:57 EDT
Randy, DefaultSelection is send when Enter is pressed on a SWT.SINGLE Text. you 
can verify this on Windows.

If the app was using DefaultSelection to close the CellEditor it would work 
(see comment 8).

When DefaultSelection happens the input process is over and the text is 
available in the widget. During the key press is indeed premature to close 
CellEditor.
Comment 19 Randy Hudson CLA 2003-06-20 15:53:04 EDT
Yes, I verified this today using GTK 2.2.0.  There are no problems with default 
selection events.

'\r' key event is the only problem.  In situations when '\r' should *not* be 
reported, it is.  When '\r' should be reported, and DBCS entry is still active 
but the candidate window is empty, the keyevent is sent twice instead of only 
once.
Comment 20 Felipe Heidrich CLA 2003-06-23 11:43:36 EDT
Randy since this problem was fixed in HEAD a couple weeks ago and it won't be
released in 2.1.1 stream (it is too risky at this point) I'm closing this bug as
won't fix.

Comment 21 Randy Hudson CLA 2003-06-23 11:49:51 EDT
You might suggest the workaround to Platform/UI, since listening to 
widgetDefaultSelected is probably both a safe change and more correct than the 
current code.
Comment 22 Randy Hudson CLA 2003-08-05 16:52:00 EDT
After re-reading all of the comments (comment #16), it seems that the current 
3.0 state is that the OS receives the ENTER key, and *then* the Text control 
receives the enter key when the candidate window is committed. This is still 
incorrect behavior. The ENTER key should not be sent at any time.

So, if I understand correctly, the user is now (in 3.0) able to insert DBCS 
characters, but once he has done so, the CellEditor applies the change and 
closes, making it really frustrating to add some kanna characters followed by 
some english characters.
Comment 23 Randy Hudson CLA 2003-08-12 16:47:30 EDT
Nick, the safest fix for enabling DBCS on GTK TextCellEditor seems to be 
changing the listener mechanism used to signal "apply".

Should we split this bug into a 3.0 SWT fix, and a 2.1.x JFace workaround?
Comment 24 Nick Edgar CLA 2003-08-14 16:01:11 EDT
If hooking DefaultSelection instead of checking key events for CR is the right 
answer, then that's what we'll do.

Felipe, please advise.

Randy, if you could enter a UI PR, with a suggested patch, that would help.
Comment 25 Felipe Heidrich CLA 2003-08-18 12:21:56 EDT
If the Text widget has the style SWT.SINGLE you can use the event 
SWT.DefaultSelection to work around this problem.
Comment 26 Randy Hudson CLA 2003-08-18 12:56:03 EDT
Felipe, In fact, this "workaround" is probably more correct than the original 
technique of listening for '\r'.  TextCellEditor has to be careful because 
createControl can be overridden, although it is extremely difficult to do this 
because you have to duplicate all of the hooking of listeners, and copy private 
methods.
Comment 27 Tim Koss CLA 2003-09-03 16:23:50 EDT
The SWT team will look at this for 2.1.2
Comment 28 Tim Koss CLA 2003-09-03 16:25:20 EDT
Felipe - can you change the milestone to 2.1.2
Comment 29 Felipe Heidrich CLA 2003-09-03 17:46:40 EDT
Fixed in HEAD (>20030903).
I've tested Motif/Gtk/Windows and they all have the same behaviour.

As said in comment#20, the fix in HEAD too much code and too risk to be back 
port to the R2_1_maintenance stream.

Leaving this pr open until we decide what to for 2.1.2.
Comment 30 Steve Northover CLA 2003-09-04 11:53:13 EDT
FH, are we sure that some other simpler hack cannot be used to fix this for 
2.1.2?
Comment 31 Felipe Heidrich CLA 2003-11-25 14:00:27 EST
closing pr.
Comment 32 Randy Hudson CLA 2004-01-14 16:46:17 EST
As of 3.0 M6, TextCellEditor is no longer forwarding keyReleased events from 
the Text Control back to its protected (and overridable!) method:
   keyReleaseOccured(KeyEvent keyEvent).

We are using a TextCellEditor with the MULTI style.  It will *never* fire 
widgetDefaultSelected, therefore we are looking for CTRL+ENTER. I'm leaving 
this bug in SWT for now for consideration of firing widgetDefaultSelected when 
CTRL+ENTER is typed into a multi-line Text widget.  If this change will not be 
made, route to JFace for them to resume sending us the keyReleaseOccured
(KeyEvent keyEvent).  BTW, they probably need to do this anyway.
Comment 33 Felipe Heidrich CLA 2004-01-20 11:33:05 EST
There is no operating system standard says we should do this. Reassigning to 
JFace.
Comment 34 Nick Edgar CLA 2004-02-16 17:09:06 EST
Made the following changes to TextCellEditor:
- calls keyReleaseOccured (sic) as before
- overrides keyReleaseOccured to:
  - pass on everything to super except for Enter (this is now handled by 
default selection)
  - handle Ctrl+Enter if the Text has SWT.MULTI style
- handling of default selection factored into new method handleDefaultSelection

Let me know if this works for you.

Comment 35 Nick Edgar CLA 2004-02-17 09:59:17 EST
We have been asked to provide a patch to 2.1.x for this.  Randy, can you 
confirm that the latest change to TextCellEditor (in HEAD, not in any 
integration build yet) addresses the problem on GTK, that it will also work on 
2.1.x, and that no SWT changes are necessary?

I'm reopening this until we get the patch in.
Comment 36 Randy Hudson CLA 2004-02-17 10:37:00 EST
AFAIK, using widgetDefaultSelected is a perfect workaround.  I would be 
cautious about the other changes which are in HEAD which are not related to 
this issue.  For example, handling CTRL+ENTER (for MULTI line) and not passing 
that event through to subclasses extending keyReleaseOccured(..).  I believe it 
was possible in 2.1.x to set celleditor styles.

We are setting a new RHE machine and will test when it is ready.
Comment 37 Nick Edgar CLA 2004-02-17 11:10:45 EST
Note that keyReleaseOccured is now called again, but is overridden in 
TextCellEditor to ignore '\r'.  But I agree that the MULTI support should be 
taken out for a patch against 2.1.x.

Comment 38 Whitney Sorenson CLA 2004-02-18 15:04:57 EST
I checked out the changes from Head and tested on M7 on GTK. The canna input 
mode works fine, no extra event was fired when the canidate selection window 
was used. Also, CTRL+ENTER is now resulting in the desired behavior of applying 
the editor value on the MUTLI TextEditor.
Comment 39 Nick Edgar CLA 2004-03-01 13:20:46 EST
Patch released to the R2_1_maintenance stream, for the next R2.1.3 candidate 
build.  This has the change to handle Enter via the default selection event 
rather than the key event, but does not include the support for multi-line text 
editors.
Comment 40 Nick Edgar CLA 2004-03-01 14:51:34 EST
Fixed in 2.1.3 and 3.0 stream.  

This PR now represents the 2.1.3 work.  If there are further problems with this 
in the 3.0 stream, please open a new PR.
Comment 41 Michael Van Meekeren CLA 2004-03-04 15:21:13 EST
verified on MOTIF on build 2.1.3RC2
Comment 42 Nick Edgar CLA 2004-03-04 23:38:47 EST
Randy, can you please verify this using 2.1.3RC2 on GTK?
Comment 43 Nick Edgar CLA 2004-03-04 23:39:21 EST
Verified on Win2000 using 2.1.3RC2.
Comment 44 Whitney Sorenson CLA 2004-03-05 11:07:34 EST
Verified on GTK using 2.1.3RC2.

However, found https://bugs.eclipse.org/bugs/show_bug.cgi?id=53876 while 
testing.
Comment 45 Chris McLaren CLA 2004-03-05 13:34:51 EST
verified on mac, using property sheet example v20030312