< prev index next >

src/java.desktop/macosx/classes/sun/lwawt/macosx/CInputMethod.java

Print this page




  84 
  85         sHighlightStyles = styles;
  86 
  87         nativeInit();
  88 
  89     }
  90 
  91     public CInputMethod() {
  92     }
  93 
  94 
  95     /**
  96         * Sets the input method context, which is used to dispatch input method
  97      * events to the client component and to request information from
  98      * the client component.
  99      * <p>
 100      * This method is called once immediately after instantiating this input
 101      * method.
 102      *
 103      * @param context the input method context for this input method
 104      * @exception NullPointerException if <code>context</code> is null
 105      */
 106     public void setInputMethodContext(InputMethodContext context) {
 107         fIMContext = context;
 108     }
 109 
 110     /**
 111         * Attempts to set the input locale. If the input method supports the
 112      * desired locale, it changes its behavior to support input for the locale
 113      * and returns true.
 114      * Otherwise, it returns false and does not change its behavior.
 115      * <p>
 116      * This method is called
 117      * <ul>
 118      * <li>by {@link java.awt.im.InputContext#selectInputMethod InputContext.selectInputMethod},
 119      * <li>when switching to this input method through the user interface if the user
 120      *     specified a locale or if the previously selected input method's
 121      *     {@link java.awt.im.spi.InputMethod#getLocale getLocale} method
 122      *     returns a non-null value.
 123      * </ul>
 124      *
 125      * @param lang locale to input
 126      * @return whether the specified locale is supported
 127      * @exception NullPointerException if <code>locale</code> is null
 128      */
 129     public boolean setLocale(Locale lang) {
 130         return setLocale(lang, false);
 131     }
 132 
 133     private boolean setLocale(Locale lang, boolean onActivate) {
 134         Object[] available = CInputMethodDescriptor.getAvailableLocalesInternal();
 135         for (int i = 0; i < available.length; i++) {
 136             Locale locale = (Locale)available[i];
 137             if (lang.equals(locale) ||
 138                 // special compatibility rule for Japanese and Korean
 139                 locale.equals(Locale.JAPAN) && lang.equals(Locale.JAPANESE) ||
 140                 locale.equals(Locale.KOREA) && lang.equals(Locale.KOREAN)) {
 141                 if (isActive) {
 142                     setNativeLocale(locale.toString(), onActivate);
 143                 }
 144                 return true;
 145             }
 146         }
 147         return false;


 188         // -- SAK: Does mac OS X support this?
 189     }
 190 
 191     /**
 192         * Composition cannot be set on Mac OS X -- the input method remembers this
 193      */
 194     public void setCompositionEnabled(boolean enable) {
 195         throw new UnsupportedOperationException("Can't adjust composition mode on Mac OS X.");
 196     }
 197 
 198     public boolean isCompositionEnabled() {
 199         throw new UnsupportedOperationException("Can't adjust composition mode on Mac OS X.");
 200     }
 201 
 202     /**
 203      * Dispatches the event to the input method. If input method support is
 204      * enabled for the focussed component, incoming events of certain types
 205      * are dispatched to the current input method for this component before
 206      * they are dispatched to the component's methods or event listeners.
 207      * The input method decides whether it needs to handle the event. If it
 208      * does, it also calls the event's <code>consume</code> method; this
 209      * causes the event to not get dispatched to the component's event
 210      * processing methods or event listeners.
 211      * <p>
 212      * Events are dispatched if they are instances of InputEvent or its
 213      * subclasses.
 214      * This includes instances of the AWT classes KeyEvent and MouseEvent.
 215      * <p>
 216      * This method is called by {@link java.awt.im.InputContext#dispatchEvent InputContext.dispatchEvent}.
 217      *
 218      * @param event the event being dispatched to the input method
 219      * @exception NullPointerException if <code>event</code> is null
 220      */
 221     public void dispatchEvent(final AWTEvent event) {
 222         // No-op for Mac OS X.
 223     }
 224 
 225 
 226     /**
 227      * Activate and deactivate are no-ops on Mac OS X.
 228      * A non-US keyboard layout is an 'input method' in that it generates events the same way as
 229      * a CJK input method. A component that doesn't want input method events still wants the dead-key
 230      * events.
 231      *
 232      *
 233      */
 234     public void activate() {
 235         isActive = true;
 236     }
 237 
 238     public void deactivate(boolean isTemporary) {
 239         isActive = false;




  84 
  85         sHighlightStyles = styles;
  86 
  87         nativeInit();
  88 
  89     }
  90 
  91     public CInputMethod() {
  92     }
  93 
  94 
  95     /**
  96         * Sets the input method context, which is used to dispatch input method
  97      * events to the client component and to request information from
  98      * the client component.
  99      * <p>
 100      * This method is called once immediately after instantiating this input
 101      * method.
 102      *
 103      * @param context the input method context for this input method
 104      * @exception NullPointerException if {@code context} is null
 105      */
 106     public void setInputMethodContext(InputMethodContext context) {
 107         fIMContext = context;
 108     }
 109 
 110     /**
 111         * Attempts to set the input locale. If the input method supports the
 112      * desired locale, it changes its behavior to support input for the locale
 113      * and returns true.
 114      * Otherwise, it returns false and does not change its behavior.
 115      * <p>
 116      * This method is called
 117      * <ul>
 118      * <li>by {@link java.awt.im.InputContext#selectInputMethod InputContext.selectInputMethod},
 119      * <li>when switching to this input method through the user interface if the user
 120      *     specified a locale or if the previously selected input method's
 121      *     {@link java.awt.im.spi.InputMethod#getLocale getLocale} method
 122      *     returns a non-null value.
 123      * </ul>
 124      *
 125      * @param lang locale to input
 126      * @return whether the specified locale is supported
 127      * @exception NullPointerException if {@code locale} is null
 128      */
 129     public boolean setLocale(Locale lang) {
 130         return setLocale(lang, false);
 131     }
 132 
 133     private boolean setLocale(Locale lang, boolean onActivate) {
 134         Object[] available = CInputMethodDescriptor.getAvailableLocalesInternal();
 135         for (int i = 0; i < available.length; i++) {
 136             Locale locale = (Locale)available[i];
 137             if (lang.equals(locale) ||
 138                 // special compatibility rule for Japanese and Korean
 139                 locale.equals(Locale.JAPAN) && lang.equals(Locale.JAPANESE) ||
 140                 locale.equals(Locale.KOREA) && lang.equals(Locale.KOREAN)) {
 141                 if (isActive) {
 142                     setNativeLocale(locale.toString(), onActivate);
 143                 }
 144                 return true;
 145             }
 146         }
 147         return false;


 188         // -- SAK: Does mac OS X support this?
 189     }
 190 
 191     /**
 192         * Composition cannot be set on Mac OS X -- the input method remembers this
 193      */
 194     public void setCompositionEnabled(boolean enable) {
 195         throw new UnsupportedOperationException("Can't adjust composition mode on Mac OS X.");
 196     }
 197 
 198     public boolean isCompositionEnabled() {
 199         throw new UnsupportedOperationException("Can't adjust composition mode on Mac OS X.");
 200     }
 201 
 202     /**
 203      * Dispatches the event to the input method. If input method support is
 204      * enabled for the focussed component, incoming events of certain types
 205      * are dispatched to the current input method for this component before
 206      * they are dispatched to the component's methods or event listeners.
 207      * The input method decides whether it needs to handle the event. If it
 208      * does, it also calls the event's {@code consume} method; this
 209      * causes the event to not get dispatched to the component's event
 210      * processing methods or event listeners.
 211      * <p>
 212      * Events are dispatched if they are instances of InputEvent or its
 213      * subclasses.
 214      * This includes instances of the AWT classes KeyEvent and MouseEvent.
 215      * <p>
 216      * This method is called by {@link java.awt.im.InputContext#dispatchEvent InputContext.dispatchEvent}.
 217      *
 218      * @param event the event being dispatched to the input method
 219      * @exception NullPointerException if {@code event} is null
 220      */
 221     public void dispatchEvent(final AWTEvent event) {
 222         // No-op for Mac OS X.
 223     }
 224 
 225 
 226     /**
 227      * Activate and deactivate are no-ops on Mac OS X.
 228      * A non-US keyboard layout is an 'input method' in that it generates events the same way as
 229      * a CJK input method. A component that doesn't want input method events still wants the dead-key
 230      * events.
 231      *
 232      *
 233      */
 234     public void activate() {
 235         isActive = true;
 236     }
 237 
 238     public void deactivate(boolean isTemporary) {
 239         isActive = false;


< prev index next >