home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 39 / IOPROG_39.ISO / SOFT / sdkjava40.exe / data1.cab / fg_Samples / Samples / afc11 / JNotepad / src / KeyFeature.java < prev    next >
Encoding:
Java Source  |  2000-05-04  |  1.4 KB  |  67 lines

  1. //
  2. // (C) Copyright 1995 - 1999 Microsoft Corporation.  All rights reserved.
  3. //
  4.  
  5. /**
  6. *    IKeyFeature
  7. *    
  8. *    Implements key-based features. Implements the key listener
  9. *    interface so it can register a listener with the text object
  10. *    it is providing features for. It intercepts the keys and modifies
  11. *    the text object accordingly.
  12. *
  13. *    @see    #KeyFeature
  14. *    @see    #IFeature
  15. *
  16. *    @version    1.0,    7/21/97
  17. */
  18.  
  19. import com.ms.ui.event.*;
  20.  
  21. public abstract class KeyFeature implements ITextFeature, IUIKeyListener
  22. {        
  23.     protected ITextOperationTargetExt textTarget;            // text target to listen to
  24.     
  25.     /**
  26.     *    Creates a new KeyFeature()
  27.     */
  28.     public KeyFeature()
  29.     {
  30.         textTarget = null;
  31.     }
  32.     
  33.     /**
  34.     *    Init function. Called when this feature is attached to a new text target
  35.     *    object.
  36.     *
  37.     *    @param    tTarget    text target to attach this feature to.
  38.     */
  39.     public void init(ITextOperationTargetExt tTarget)
  40.     {
  41.         textTarget = tTarget;
  42.     }
  43.     
  44.     /**
  45.     *    Called when the feature is attached to a text target. Adds a key listener
  46.     *    to the text target.
  47.     */
  48.     public void register()
  49.     {
  50.         textTarget.addKeyListener(this);
  51.     }
  52.     
  53.     /**
  54.     *    Called when the feature is detached from the text target. Removes the key
  55.     *    listener.
  56.     */
  57.     public void unregister()
  58.     {
  59.         textTarget.removeKeyListener(this);
  60.     }
  61.     
  62.     // reset() and all IUIKeyListener functions are to be
  63.     // implemented in a child class.
  64.     
  65. }
  66.  
  67.