### IFocusHandler

  The IFocusHandler class handles events occurring when a control gains or loses the input focus, such as when the user tabs to or from an entry field. These objects handle the processing of focus change events for the following controls:

  - IContainerControl
  - IEntryField
  - IListBox
  - IMultiLineEdit
  - ISlider
  - ICircularSlider
  - INumericSpinButton
  - ITextSpinButton

  Create a handler derived from IFocusHandler and attach it to the control that gets or loses the input focus, or to the owner window of the control. You can do this by calling IHandler::handleEventsFor to pass this control or owner window to the focus handler.

  When the focus handler receives a focus event, it creates an object of class IControlEvent and routes that object to the appropriate IFocusHandler virtual function. You can override these "Event Processing" virtual functions to supply your own specialized processing of a focus event.

  The return value from the virtual functions specifies whether the focus event is passed on for additional processing, as follows:

  true
    The focus event requires no additional processing. Do not pass it to another handler.
  false
    Pass the focus event to the next handler for additional processing, as follows:
    - If there is another handler for the control, pass the focus event to the next handler.
    - If this is the last handler for the control, call IWindow::dispatch to dispatch the focus event to the control's owner window.
    - If this is the last handler for the owner window, call IWindow::defaultProcedure to process the focus event.

#### AIX Considerations

  In Motif, IFocusHandlers cannot handle the processing of focus change events for ISlider controls.

### IFocusHandler - Member Functions and Data by Group

### Constructors & Destructor

You can construct and destruct objects of this class.

~IFocusHandler

      public:
      virtual ~IFocusHandler()

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

IFocusHandler

      public:
      IFocusHandler()

  Constructs the default focus handler.

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

### Event Dispatching

The Open Class Library dispatches events that have been sent or posted to a window to the handlers attached to that window. It does this by calling the event-dispatching function of the handler objects. An IFocusHandler object processes only focus-change events.

dispatchHandlerEvent

      protected:
      virtual bool dispatchHandlerEvent(IEvent& event)

  If a focus event is received, this function calls the appropriate virtual function.

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

### Event Processing

A focus handler allows you to process focus changes through its event-processing members. Override at least one of these virtual functions in a derived class.

gotFocus

      protected:
      virtual bool gotFocus(IControlEvent& event)

  Implemented by a derived class to process a gain-focus event. Avoid trying to set focus to another window from within this method; attempting to change focus while a previous focus change is being processed has unpredictable results. An alternative is to post yourself another event from within this method and reset the focus during processing of this other event.

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

lostFocus

      protected:
      virtual bool lostFocus(IControlEvent& event)

  Implemented by a derived class to process a lost-focus event. As is true for most virtual methods of handler classes, you should not typically perform any long-running operations in your implementation of this method. This particular virtual method is especially sensitive to long delays in returning to the caller; doing so has unpredictable results including hanging your system. If you must perform a long-running operation, spin off a separate thread to do it and return from this method as soon as possible to free up the thread this method was called on..

  Avoid trying to set focus to another window from within this method; attempting to change focus while a previous focus change is being processed has unpredictable results. An alternative is to post yourself another event from within this method and reset the focus during processing of this other event.
  Note: It is possible that a set-focus event can be ahead of a related lost-focus event on the message queue.

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

### IFocusHandler - Inherited Member Functions and Data

#### Inherited Public Functions

  IHandler

  -     virtual ~IHandler()

  -     virtual IString asDebugInfo() const

  -     virtual IString asString() const

  -     virtual IHandler& disable()

  -     virtual IHandler& enable(bool enable = true)

  -     virtual IHandler& handleEventsFor(IWindow* window)

  -     IHandler()

  -     bool isEnabled() const

  -     virtual IHandler& stopHandlingEventsFor(IWindow* window)

#### Inherited Public Data

  - None

#### Inherited Protected Functions

  IHandler

  -     virtual IEventResult defaultProcedure(IEvent& event)

  -     virtual bool dispatchHandlerEvent(IEvent& event) = 0

#### Inherited Protected Data

  - None