Community
Participate
Working Groups
Build ID: M20080911-1700 Steps To Reproduce: Using EPF: 1.5 build 20080714-1745, on windows XP We're using the RichTextEditor in some modal dialogs, and have noticed that the events we're hooked into (ModifyEvent and KeyEvent) are not always being fired when we would expect them to. I can generally be guaranteed that these events will fire if I select the FontStyle combo or if I hit return, but that's about it. The way we're hooking in has varied. Right now, on my class extending RichTextEditor, I hook into modify as follows... richEditor.addModifyListener(new ModifyListener(){ public void modifyText(ModifyEvent e) { //enable some button } }); I've also tried doing the same, via richEditor.getRichTextControl().addModifyListener as well as both the preceding with addKeyListener. I know that there have been issues with using the RichTextEditor within dialogs in the past. Perhaps there is still some quirk of event firing in the RichTextEditor when being used in this fashion? More information:
Please investigate this one.
Hi, I wrote a test plugin to simulate the behavior. But I can't reproduce this issue. My plugins is like this: 1. prepare a editor that extends EditorPart and implements IEditorInput, which will be used to provide editorSite to RTE 2. prepare a dialog that has a MethodRichTextEditor. The code is as below: protected Control createDialogArea(Composite parent) { Composite baseComposite = (Composite) super.createDialogArea(parent); MethodRichTextEditor rte = new MethodRichTextEditor(baseComposite, SWT.MULTI | SWT.WRAP | SWT.V_SCROLL, null, null, new Label(baseComposite, SWT.CENTER),editor.getEditorSite()); rte.addModifyListener(new ModifyListener(){ public void modifyText(ModifyEvent e) { System.out.println("get modificaiton event: "+(count++)); } }); //RTE configuration return baseComposite; } 3. when the test action is activated, the editor is intantiated. The editor's editorSite is then passed for dialog instantiation. I tried editing actions like changing font style, inputting new characters, removing text, etc., I can always receive the modify event. Can you show me your code?
Hi, It seems this doesn't happen on every Windows machine. The only thing we do is add a modify listener to the RichText that we're using. After debugging on a machine where it doesn't work, it turns out that the status text change events that should be fired from the browser aren't. The OLE code that should be creating them isn't doing what it should, it seems.
We have hit this on multiple WinXP systems. Basically no key events are trigerred till you hit ENTER key. In the SWT Browser internals, the org.eclipse.swt.browser.IE class's OLEListener never gets any events (StatusTextChange). We have both systems which work, and those which dont - we will be more than happy to let you debug on the problem machines if you cant reproduce it. This problem is a major one for us, as the rich text editor plays an important part in our tools usecase.
Hi, Has anyone had a chance yet to take another look at this problem? As Sri mentioned on May 1st this is a big deal for our tooling and we'd love to know whether there is anything that can be done about it. Thanks. Richard
I can't reproduce it on my two XP box. Both install IE7. Can you try to figure out where's the difference between the working system and non-working system? Such as checking IE versions? Or you can try using firefox by updating the Browser instantiate function in org.eclipse.epf.richtext.RichText.java with this code so as to see if it's browser issue or not? public RichText(Composite parent, int style, String basePath) { .... try { editor = new Browser(parent, SWT.MOZILLA);
Hi, I did try instantiating the browser with SWT.MOZILLA, but it doesn't seem to make any difference. The behavior is the same as when I used IE. I was using XULRunner 1.9.x to do the test. The IE version I have is 7 and I'm running on XP Pro SP2.
Created attachment 137574 [details] test case to try to reproduce
In comment #8 I attached a project to attempt to help isolate the issue. This project uses plain SWT (no EPF RichText). It creates a Dialog with a Browser widget in editing mode. It attaches a key listener that outputs to the console when a KeyUp occurs. This is the same method that the EPF RichText uses in the ModifyListener. You did not specify which version of Eclipse you are using, so I used Eclipse 3.3.2, which is what EPF 1.5 is based on. If you use a different version of Eclipse you'll have to fix the build path for the project. Please try this on your affected machines - if the problem is reproducible, this indicates an SWT problem. If the problem doesn't occur, then EPF RichText must be causing the issue somehow.
So I tried the test that Jeff handed to me. It didn't deliver the events at all. I did add in a keyListener, which delivered the events as I would expect. Jeff, you were saying that you thought this was an SWT problem, right?
Yes, please file a new bug against SWT and list the bugzilla number here. You may want to attach the test case so they can reproduce it.
Is there some reason why this bug can't be moved to SWT?
The SWT guys probably want their own bug for the issue. This bug tracks the issue as it affects EPF.
Hi Ricard, Which version of Eclispe do you use? As Jeff mentioned, we are still on Eclispe 3.3.2, and have not verified this on neither 3.4 or 3.5. Thanks.
I'm running 3.4.1
I've also run Jeff's test on 3.4.2 and 3.5, with the same results.
Thanks much for the testing. Please try it on Eclipse 3.3.x and if it works, then it would be very easy for the SWT team to figure out the difference between them.
Just for the record... if you modify Jeff's test to do this... browserControl.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { System.out.println("KeyPressed: " + e.widget); } }); ... it displays KeyPressed just fine. Jeff, I also tried running your test on 3.3.2 and it works fine. Since it's obvious that SWT has changed something about the way they handle key events from 3.3.x to 3.4.x, can we look into getting it to work on these platforms? There are quite a few products out there running on 3.4 and above at this point.
Opened https://bugs.eclipse.org/bugs/show_bug.cgi?id=280146 against SWT
Jeff and Dancy, Will the comments in #18 can be incorporated into the current RTE code to resolve the problem in Eclipse 3.4 or 3.5?
RAM is currently required to support Eclipse 3.4 and 3.5, so it would be great if this could be fixed.
The fix is under testing. We'll deliver the fix once it passes the test.
Created attachment 140176 [details] patch for IES3.4.X and IES3.5 compatibility
The patch passed unit test based on IES 3.5 and IES 3.4.2. Since EPF doesn't support IES3.4.2 and IES 3.5, can you apply this patch and help on integration test on your system?
I tried the patch on my 3.4.2-based target and it works! We'd be very interested in finding out when a new version with this fix will be available, as we ship EPF in our update site. Thanks!
Let me qualify that last statement... we ship the RTE from EPF, not all of EPF.
The next EPF release 1.5.0.4 is schedlued for Oct. 10, 2009 (both EPF Composer and the RTE feature). Thanks.
fixed
I just updated to version 1.5.0.4 and using Eclipse 3.5.1. I still don't receive the Modify and KeyEvents. This is my test code: Shell shell = new Shell(Display.getCurrent().getActiveShell(), SWT.CLOSE); shell.setLayout(new FillLayout()); IRichText richTextComponent = RichTextFormToolkit.createRichText(new FormToolkit(Display.getCurrent()), shell, null, SWT.NONE); richTextComponent.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { System.out.println("modifyText " + e); } }); richTextComponent.addKeyListener(new KeyListener() { @Override public void keyReleased(KeyEvent e) { System.out.println("keyReleased " + e); } @Override public void keyPressed(KeyEvent e) { System.out.println("keyPressed " + e); } }); shell.open(); I would like to get EVERY key stroke. Right now I only get ModifyEvents when hitting ENTER, F1-F12 Buttons, KeyPad and such, but not the normal keyboard including numbers. Is this a new issue, am I doing something wrong?
Am I expecting the wrong behavior as described in the comment above?
(In reply to comment #30) > Am I expecting the wrong behavior as described in the comment above? This is a SWT problem in eclipse 3.4 and above. This issue can be workarounded by using KeyAdaptor to replace KeyListener, just like the following sample: browserControl.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { System.out.println("KeyPressed: " + e.widget); } });
I just downloaded the attached test case and yes I only get the keyevents when I change the listener to a KeyAdapter. Still adding a KeyAdapter or ModifyListener my IRichText does not forward these events. I made a little Test Plug-in (will attach it), maybe you can try it out and tell me if you get any output in the console when typing. View.java IRichText richText = RichTextFormToolkit.createRichText(toolkit, parent, null, SWT.NONE); richText.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { System.out.println("modifyText: " + e); } }); richText.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { System.out.println("keyPressed: " + e); } }); BTW I'm using Eclipse 3.5.1
Created attachment 154748 [details] EPF RichtText Test Plug-in
I gave the test to two of our other software developers. The modify event works on their machine: Windows XP Media Center Editon Version 2002 SP3 Internet Explorer 8.0.6001.18702 Windows Vista Business Service Pack 2 Internet Explorer 8.0.6001.18865 On mine the test fails. I don't get any modify events. Windows XP Professional Version 2002 Service Pack 3 Internet Explorer 8.0.6001.18702 Is this a SWT bug?
Sorry my fault it doesn't work on their machine either. They still had my "hacked" bundles in the TargetPlatform (see http://www.eclipse.org/forums/index.php?t=tree&th=16670&S=28cf035914bb5b2b73482ea57f1ed6c8#page_top).
on Windows, you need to use editorControl to manage the listener. Following code is an sample: Control browserControl = getControlSite((Composite)richText.getRichTextControl().getControl()); browserControl.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { System.out.println("keyPressed: " + e); } }); protected Control getControlSite(Composite composite) { Control[] controls = composite.getChildren(); for (int i = 0; i < controls.length; i++) { String controlClass = controls[i].getClass().getName(); if (controlClass.equals("org.eclipse.swt.browser.WebSite")) { //$NON-NLS-1$ return controls[i]; } else if (controls[i] instanceof Composite) { return getControlSite((Composite) controls[i]); } } return null; }
Hi Xiao Dan Xia, Thanks for this tip. I do get the KeyEvents now. But shouldn't this issue be reopened since this is a workaround? I still don't get the modify events. I have a different problem with the solution you describe. I want to use databinding so I added a KeyAdapter and want to update my business object on every keystroke. public void keyReleased(KeyEvent e) { String newValue = editor.getText(); ... } Now when I type 'abc' I do get the 'c' event but the 'newValue' is still 'ab'. Storing my business object the value is cut of 'ab' instead of 'abc'. Maybe this would work with the modify event but since I don't receive those I'm screwed :-).
I'd suggest opening a bug or discussion against SWT/broswer widget by preparing some test plug-ins directly to prove or disapprove the events are been sent or received. If those are bugs or inteneded changes with the newer versions of SWT, EPF could not fix them. Thanks.
I tried my test plugin on eclipse 3.3.2 and eclipse 3.5.0. On eclipse 3.3.2, modify event can be received and text can be correctly retrieved. On eclipse 3.5.0, I can't get modify event as well as keyReleased event(I can get keyPressed event). So, it should be a SWT problem. Can you try your plugin on eclipse3.3.2? BTW, there's already a bug against SWT(https://bugs.eclipse.org/bugs/show_bug.cgi?id=280146) to track keyUp issue. You may add comments and discussion there.
I've tested my test plug-in with eclipse 3.2.2 and I do get the ModifyEvents and keyPressed. As mentioned above I have done some hacking in the passed (July 2009) on the rte.js file. Afterwards I did get ModifyEvents using eclipse 3.5.1 but still having a strange behavior. see the following link for details: http://www.eclipse.org/forums/index.php?t=tree&th=16670&S=28cf035914bb5b2b73482ea57f1ed6c8#page_top I actually "don't care" about the KeyEvents, I would rather get the modify events for my databinding. Maybe fixing the rte.js file would solve the issue?
For your case, as a workaround, you can try move your change to function keyReleased() and attach keyrelease event to this function. Refer to following code fragment. function enableRichTextEditing(html) { ... if ("attachEvent" in doc) { doc.attachEvent("onkeyup", keyReleased); .... } if ("addEventListener" in doc) { doc.addEventListener("keypress", keyPressed, true); doc.addEventListener("keyrelease", keyReleased, true); ... } function keyReleased(event) { var keyCode = event.keyCode; if (keyCode == 0 && !document.all) { keyCode = event.charCode; switch (keyCode) { case 98: keyCode = KEY_B; break; case 99: keyCode = KEY_C; break; case 102: keyCode = KEY_F; break; case 105: keyCode = KEY_I; break; case 115: keyCode = KEY_S; break; case 117: keyCode = KEY_U; break; case 118: keyCode = KEY_V; break; case 120: keyCode = KEY_X; break; case 122: keyCode = KEY_Z; break; } } var ctrlKey = event.ctrlKey; var shiftKey = event.shiftKey; var altKey = event.altKey; if ( !ctrlKey && !altKey ) { var modified = true; for (var i = 0; i < excludeModify.length; i++ ) { if ( keyCode == excludeModify[i] ) { modified = false; } } if ( modified == true ) { setTimeout("setStatus(STATUS_MODIFIED, null);", 10); } } }
Thanks a lot. I do now get my desired ModifyEvents. Also when CTRL or ALT is pressed but that doesn't matter I can handle this in my listener. But shouldn't this issue be reopened since there are still problems around? greets and thanks again!
I run test posted by Jeff Hardy using an addKeyListener(KeyAdapter) instead addListener on eclipse 3.6, every time i press a key, console log correctly. So SWT browser widget haven't problem to catch key event. Running test post by Flavio Donzé that already use addKeyListenet(KeyAdapter), listener is waked up only on backspace, canc or enter was. Instead key listener never print to console "keyPressed..." message.
I run on Windows XP SP3 My browser are: Internet Explorer 8.0.6001.18702 Firefox 3.6.8