Package com.iizix.gyro
Interface IFocusEngine
- All Known Subinterfaces:
IVirtualSpaceFocusEngine
public interface IFocusEngine
Interface implemented by the focus engine.
Focus processing is done in the following order:
- Focus is changed in the focus engine without notification, i.e. the call to
getCurrentFocus()
will reflect the new focus component,
- If the receiving focus component is non-null: focus veto processing using the focus listeners registered in the
IFocusEngine
using theIFocusVetoListener
interface. If theFocusVetoException
is thrown, the original focus is restored in the focus engine without notification.
- Focus lost sent to the component losing focus using method
IFocusComp.onFocusLost(IFocusComp, IGProp, boolean)
in the eventFocusEvent
.
- Focus lost is notified in a bubbling event
PropFocusEvent
to the component losing focus and its parents. withPropFocusEvent.isFocusLost()
true
.
- Focus lost is notified in a sinking event
PropCnrFocusEvent
to the component losing focus and its descendants withPropCnrFocusEvent.isFocusLost()
true
.
- Focus change sent to the focus listeners registered in the
IFocusEngine
usingIFocusListener.onFocusChanged(FocusEvent)
.
- Focus gained sent to the component gaining focus using method
IFocusComp.onFocusGained(IFocusComp, IGProp, boolean)
in the eventFocusEvent
.
- Focus gained is notified in a bubbling event
PropFocusEvent
to the component gaining focus and its parents. withPropFocusEvent.isFocusGained()
true
.
- Focus gained is notified in a sinking event
PropCnrFocusEvent
to the component gaining focus and its descendants withPropCnrFocusEvent.isFocusGained()
true
.
- Author:
- Christopher Mindus
Method Summary
Modifier and TypeMethodDescriptionboolean
addFocusListener
(IFocusListener listener) Adds a focus listener to the engine.boolean
addFocusVetoListener
(IFocusVetoListener listener) Adds a veto focus listener to the engine.Gets the component in focus.Gets the current focus listeners.Gets the current veto focus listeners.boolean
Checks if this focus engine is common to all parallel client sessions.boolean
removeFocusListener
(IFocusListener listener) Removes a focus listener from the engine.boolean
removeFocusVetoListener
(IFocusVetoListener listener) Removes a veto focus listener from the engine.requestFocus
(IFocusComp comp, IGProp<?> trigger, boolean isRemoteInduced, IFocusVetoListener callback) Requests focus to this component.boolean
requestFocusEx
(IFocusComp comp, IGProp<?> trigger, boolean isRemoteInduced, IFocusVetoListener callback) Requests focus to this component.
Method Details
hasCommonFocus
boolean hasCommonFocus()Checks if this focus engine is common to all parallel client sessions. E.g. the VirtualSpace engine returns true, and the Panel engine returns false.- Returns:
- true if the focus engine is common to all parallel client session, false otherwise.
requestFocus
String requestFocus(IFocusComp comp, IGProp<?> trigger, boolean isRemoteInduced, IFocusVetoListener callback) Requests focus to this component. This call is redirected to the focus engine for the component type. The engine may veto the focus change, because it currently cannot change focus, or the request is not or cannot be virtualized.This method is less precise than
requestFocusEx(IFocusComp, IGProp, boolean, IFocusVetoListener)
, but avoid try-catching.- Parameters:
comp
- The component requesting focus.trigger
- The trigger property, null for none.isRemoteInduced
- Flag for remote induced focus.callback
- Optional callback that may throw a veto exception, null for none. This callback is intended to perform focus changes in the tree, typically for UI containers.- Returns:
null
for success, otherwise an error message indicating why focus was not able to be changed.- Throws:
NullPointerException
- Ifcomp
is null.
requestFocusEx
boolean requestFocusEx(IFocusComp comp, IGProp<?> trigger, boolean isRemoteInduced, IFocusVetoListener callback) throws FocusException Requests focus to this component. This call is redirected to the focus engine for the component type. The engine may veto the focus change, because it currently cannot change focus, or the request is not or cannot be virtualized.- Parameters:
comp
- The component requesting focus.trigger
- The trigger property, null for none.isRemoteInduced
- Flag for remote induced focus.callback
- Optional callback that may throw a veto exception, null for none. This callback is intended to perform focus changes in the tree, typically for UI containers.- Returns:
- true if focus was changed, false otherwise.
- Throws:
FocusException
- If focus could not be changed.NullPointerException
- Ifcomp
is null.
getCurrentFocus
IFocusComp getCurrentFocus()Gets the component in focus.- Returns:
- The component or property in current focus, null for none.
addFocusListener
Adds a focus listener to the engine.- Parameters:
listener
- The focus listener.- Returns:
- true if the listener is added, false if already added as a listener previously.
addFocusVetoListener
Adds a veto focus listener to the engine.- Parameters:
listener
- The veto focus listener.- Returns:
- true if the listener is added, false if already added as a listener previously.
removeFocusListener
Removes a focus listener from the engine.- Parameters:
listener
- The focus listener.- Returns:
- true if the listener is removed, false if not present.
removeFocusVetoListener
Removes a veto focus listener from the engine.- Parameters:
listener
- The veto focus listener.- Returns:
- true if the listener is removed, false if not present.
getFocusListeners
IFocusListener[] getFocusListeners()Gets the current focus listeners.- Returns:
- An array of the focus listeners.
getFocusVetoListeners
IFocusVetoListener[] getFocusVetoListeners()Gets the current veto focus listeners.- Returns:
- An array of the veto focus listeners.