Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6609480

[Win] Input methods can't consume KeyEvents containing [Backspace]

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P4 P4
    • None
    • 1.4.2
    • client-libs

      FULL PRODUCT VERSION :
      java version "1.4.2"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-b28)
      Java HotSpot(TM) Client VM (build 1.4.2-b28, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows 2000 [Version 5.00.2195]

      A DESCRIPTION OF THE PROBLEM :
      Input methods can't consume KeyEvents containing [Backspace].

      If an input method get's a KEY_TYPED KeyEvent containing the keyChar [Backspace] and consumes this event, the very event will still be handled by the targeted (J)TextArea,

      Write a character in an TextField, the type Backspace and the _consumed_ KeyEvent will delete the character.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. compile the attached source

      2. pack it in a jar

      3. add the file META-INF/services/java.awt.im.spi.InputMethodDescriptor with the content :
      net.sourceforge.jgim.debug.XBackspace
      to the jar.

      4. place the jar in the java ext. dir

      5. start an GUI / Swing application

      6. select the input method XBackspace

      7. type a character

      8. type [Backspace]

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      the text shoud not be changed after pressing [Backspace]
      ACTUAL -
      the character in front of the carret is deleted

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package net.sourceforge.jgim.debug;

      import java.awt.im.spi.*;
      import java.awt.im.*;
      import java.awt.*;
      import java.awt.event.*;
      import java.util.Locale;

      public class XBackspace implements InputMethodDescriptor,InputMethod {
          
          private static Locale locale = new Locale("de","","XBackspace");
          private InputMethodContext Context;
         
          public void dispatchEvent(AWTEvent event) {
      if(event.getID()==KeyEvent.KEY_TYPED){
      KeyEvent keyEvent = (KeyEvent) event;
      if(keyEvent.getKeyChar()=='\b'){
      keyEvent.consume(); // try to cancel [Backspace]
      }
      }
          }
         
          public XBackspace(){}
              
          public boolean setLocale(Locale requestLocale) {
      return requestLocale.equals(locale);
          }
          
          public void setInputMethodContext(InputMethodContext context) {
      Context = context;
          }
             
          public Locale[] getAvailableLocales(){ return new Locale[]{locale}; }
          
          public String getInputMethodDisplayName(Locale inputLocale, Locale displayLanguage) {
      return "Backspace Debug";
          }
          
          public Locale getLocale() { return locale; }
          
          public boolean hasDynamicLocaleList() { return false; }
          
          public boolean isCompositionEnabled() { return false; }
          
          public void reconvert() { throw new UnsupportedOperationException();}
          
          public Image getInputMethodIcon(Locale inputLocale) { return null; }
          
          public void removeNotify() {}
          
          public void setCharacterSubsets(java.lang.Character.Subset[] subsets) {}
          
          public void setCompositionEnabled(boolean enable) {}
          
          public void notifyClientWindowChange(java.awt.Rectangle bounds) {}
          
          public void hideWindows() {}
          
          public Object getControlObject() { return null; }
          
          public void activate() {}
          
          public InputMethod createInputMethod(){return this;}

          public void deactivate(boolean isTemporary) {}
          
          public void dispose() {}

          public void endComposition() {}
      }

      ---------- END SOURCE ----------

            nishjain Nishit Jain
            okutsu Masayoshi Okutsu
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: