com.swfm.mica.core
Class MiKeyboardFocusManager

java.lang.Object
  extended bycom.swfm.mica.core.MiKeyboardFocusManager

public class MiKeyboardFocusManager
extends java.lang.Object

This class manages the assignment and traversal of keyboard and enter key focus to parts in a window. It also manages the forwarding of keyboard events to the part with keyboard focus and forwarding of enter key events to the part with enter key focus.

Version:
%I% %G%
Author:
Michael L. Davis

Field Summary
static int Mi_KEYBOARD_FOCUS_ONLY_KEYBOARD_FOCUS_POLICY
           
static int Mi_KEYBOARD_FOCUS_THEN_MOUSE_KEYBOARD_FOCUS_POLICY
           
static int Mi_MOUSE_THEN_KEYBOARD_FOCUS_KEYBOARD_FOCUS_POLICY
           
 
Constructor Summary
MiKeyboardFocusManager(MiWindow window)
          Constructs a new MiKeyboardFocusManager.
 
Method Summary
 void clearEnterKeyFocus()
          Remove enter key focus from the part with the current keyboard focus, if any.
 void clearKeyboardFocus()
          Remove keyboard focus from the part with the current keyboard focus, if any.
 MiPart getDefaultEnterKeyFocus()
          Gets the default enter key focus.
 MiPart getDefaultKeyboardFocus()
          Gets the default keyboard focus.
 MiPart getEnterKeyFocus()
          Get the part with the current enter key focus, if any.
 MiPart getKeyboardFocus()
          Get the part with the current keyboard focus, if any.
 int getKeyboardFocusPolicy()
          Returns the keyboard focus policy.
 MiWindow getSubject()
          Get the subject container within which this manages keyboard focus.
 void moveFocusToNext()
          Advance the keyboard to the next valid part.
 void moveFocusToPrevious()
          Advance the keyboard to the previous valid part.
 void setDefaultEnterKeyFocus(MiPart part)
          Sets the default enter key focus.
 void setDefaultKeyboardFocus(MiPart part)
          Sets the default keyboard focus to the given part.
 void setKeyboardFocusPolicy(int policy)
          Set the keyboard focus policy.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

Mi_MOUSE_THEN_KEYBOARD_FOCUS_KEYBOARD_FOCUS_POLICY

public static final int Mi_MOUSE_THEN_KEYBOARD_FOCUS_KEYBOARD_FOCUS_POLICY
See Also:
Constant Field Values

Mi_KEYBOARD_FOCUS_ONLY_KEYBOARD_FOCUS_POLICY

public static final int Mi_KEYBOARD_FOCUS_ONLY_KEYBOARD_FOCUS_POLICY
See Also:
Constant Field Values

Mi_KEYBOARD_FOCUS_THEN_MOUSE_KEYBOARD_FOCUS_POLICY

public static final int Mi_KEYBOARD_FOCUS_THEN_MOUSE_KEYBOARD_FOCUS_POLICY
See Also:
Constant Field Values
Constructor Detail

MiKeyboardFocusManager

public MiKeyboardFocusManager(MiWindow window)
Constructs a new MiKeyboardFocusManager. The default keyboard focus policy is Mi_KEYBOARD_FOCUS_THEN_MOUSE_KEYBOARD_FOCUS_POLICY

Parameters:
window - the root window that this will manage.
Method Detail

setKeyboardFocusPolicy

public void setKeyboardFocusPolicy(int policy)
Set the keyboard focus policy. Valid policies are: Mi_MOUSE_THEN_KEYBOARD_FOCUS_KEYBOARD_FOCUS_POLICY Forward key events to the part underneath the mouse and then, if not consumed, send it to the part with keyboard focus. . Mi_KEYBOARD_FOCUS_ONLY_KEYBOARD_FOCUS_POLICY Forward key events to the part with keyboard focus and then consume event, do not send it to the part underneath the mouse. Mi_KEYBOARD_FOCUS_THEN_MOUSE_KEYBOARD_FOCUS_POLICY Forward key events to the part with keyboard focus and then, if not consumed, send it to the part underneath the mouse. This is the default value. Mi_NONE No key events are forwarded.

Parameters:
policy - the new policy

getKeyboardFocusPolicy

public int getKeyboardFocusPolicy()
Returns the keyboard focus policy.

Returns:
the current keyboard focus policy
See Also:
setKeyboardFocusPolicy(int)

getSubject

public MiWindow getSubject()
Get the subject container within which this manages keyboard focus.

Returns:
the subject

setDefaultKeyboardFocus

public void setDefaultKeyboardFocus(MiPart part)
Sets the default keyboard focus to the given part. This part is assigned keyboard focus whenever the associated window is made visible after being invisible.

Parameters:
part - the first part to get keyboard focus

getDefaultKeyboardFocus

public MiPart getDefaultKeyboardFocus()
Gets the default keyboard focus. This part is assigned keyboard focus whenever the associated window is made visible after being invisible.

Returns:
the first part to get keyboard focus

setDefaultEnterKeyFocus

public void setDefaultEnterKeyFocus(MiPart part)
Sets the default enter key focus. This part is assigned enter key focus whenever the associated window is made visible after being invisible.

Parameters:
part - the first part to get enter key focus

getDefaultEnterKeyFocus

public MiPart getDefaultEnterKeyFocus()
Gets the default enter key focus. This part is assigned enter key focus whenever the associated window is made visible after being invisible.

Returns:
the first part to get enter key focus

getKeyboardFocus

public MiPart getKeyboardFocus()
Get the part with the current keyboard focus, if any.

Returns:
the part with keyboard focus.

clearKeyboardFocus

public void clearKeyboardFocus()
Remove keyboard focus from the part with the current keyboard focus, if any.


getEnterKeyFocus

public MiPart getEnterKeyFocus()
Get the part with the current enter key focus, if any.

Returns:
the part with enter key focus.

clearEnterKeyFocus

public void clearEnterKeyFocus()
Remove enter key focus from the part with the current keyboard focus, if any.


moveFocusToNext

public void moveFocusToNext()
Advance the keyboard to the next valid part. If this part also accepts enter key focus then enter key focus is also set to this part. This is used internally by tab key traversals.


moveFocusToPrevious

public void moveFocusToPrevious()
Advance the keyboard to the previous valid part. If this part also accepts enter key focus then enter key focus is also set to this part. This is used internally by tab key traversals.