Class BehaviorBase<C extends Control>
- Direct Known Subclasses:
ButtonBehavior
,ScrollPaneBehavior
,TabPaneBehavior
,TextInputControlBehavior
,TitledPaneBehavior
Although BehaviorBase is typically used as a base class, it is not abstract and several skins instantiate an instance of BehaviorBase directly.
BehaviorBase also implements the hooks for focus traversal. This implementation is sufficient for most subclasses of BehaviorBase. The following action names are registered in the keyMap for handling focus traversal. Subclasses which need to invoke focus traversal using non-standard key strokes should map key strokes to these action names:
- TraverseUp
- TraverseDown
- TraverseLeft
- TraverseRight
- TraverseNext
- TraversePrevious
Note that by convention, action names are camel case with the first letter uppercase, matching class naming conventions.
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final boolean
A static final reference to whether the platform we are on supports touch.protected static final List<KeyBinding>
The default key bindings for focus traversal. -
Constructor Summary
ConstructorDescriptionBehaviorBase
(C control, List<KeyBinding> keyBindings) Create a new BehaviorBase for the given control. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
callAction
(String name) Called to invoke the action associated with the given name.protected void
Invokes the appropriate action for this key event.void
dispose()
Called by a Skin when the Skin is disposed.protected void
Called whenever the focus on the control has changed.final C
Gets the control associated with this behavior.protected String
Given a key event, this method will find the matching action name, or null if there is not one.void
Invoked by a Skin when the body of the control has been dragged by the mouse.void
Invoked by a Skin when the body of the control has been entered by the mouse.void
Invoked by a Skin when the body of the control has been exited by the mouse.void
Invoked by a Skin when the body of the control has been pressed by the mouse.void
Invoked by a Skin when the body of the control has been released by the mouse.
-
Field Details
-
IS_TOUCH_SUPPORTED
protected static final boolean IS_TOUCH_SUPPORTEDA static final reference to whether the platform we are on supports touch.- See Also:
-
TRAVERSAL_BINDINGS
The default key bindings for focus traversal. For many behavior implementations, you may be able to use this directly. The built in names for these traversal actions are:- TraverseUp
- TraverseDown
- TraverseLeft
- TraverseRight
- TraverseNext
- TraversePrevious
-
-
Constructor Details
-
BehaviorBase
Create a new BehaviorBase for the given control. The Control must not be null.- Parameters:
control
- The control. Must not be null.keyBindings
- The key bindings that should be used with this behavior. Null is treated as an empty list.
-
-
Method Details
-
dispose
public void dispose()Called by a Skin when the Skin is disposed. This method allows a Behavior to implement any logic necessary to clean up itself after the Behavior is no longer needed. Calling dispose twice has no effect. This method is intended to be overridden by subclasses, although all subclasses must call super.dispose() or a potential memory leak will result. -
getControl
Gets the control associated with this behavior. Even after the BehaviorBase is disposed, this reference will be non-null.- Returns:
- The control for this Behavior.
-
callActionForEvent
Invokes the appropriate action for this key event. This is the main entry point where key events are passed when they occur. This method is responsible for invoking matchActionForEvent, callAction, and consuming the event if it was handled by this control.- Parameters:
e
- The key event. Must not be null.
-
matchActionForEvent
Given a key event, this method will find the matching action name, or null if there is not one.- Parameters:
e
- The key event. Must not be null.- Returns:
- The name of the action to invoke, or null if there is not one.
-
callAction
Called to invoke the action associated with the given name.When a KeyEvent is handled, it is first passed through callActionForEvent which resolves which "action" should be executed based on the key event. This action is indicated by name. This name is then passed to this function which is responsible for invoking the right function based on the name.
-
focusChanged
protected void focusChanged()Called whenever the focus on the control has changed. This method is intended to be overridden by subclasses that are interested in focus change events. -
mousePressed
Invoked by a Skin when the body of the control has been pressed by the mouse. Subclasses should be sure to call super unless they intend to disable any built-in support.- Parameters:
e
- the mouse event
-
mouseDragged
Invoked by a Skin when the body of the control has been dragged by the mouse. Subclasses should be sure to call super unless they intend to disable any built-in support (for example, for tooltips).- Parameters:
e
- the mouse event
-
mouseReleased
Invoked by a Skin when the body of the control has been released by the mouse. Subclasses should be sure to call super unless they intend to disable any built-in support (for example, for tooltips).- Parameters:
e
- the mouse event
-
mouseEntered
Invoked by a Skin when the body of the control has been entered by the mouse. Subclasses should be sure to call super unless they intend to disable any built-in support.- Parameters:
e
- the mouse event
-
mouseExited
Invoked by a Skin when the body of the control has been exited by the mouse. Subclasses should be sure to call super unless they intend to disable any built-in support.- Parameters:
e
- the mouse event
-