}
mController->KeyboardFocusGainEvent();
+
+ EmitKeyInputFocusSignal( true ); // Calls back into the Control hence done last.
}
void TextField::OnKeyInputFocusLost()
}
mController->KeyboardFocusLostEvent();
+
+ EmitKeyInputFocusSignal( false ); // Calls back into the Control hence done last.
}
void TextField::OnTap( const TapGesture& gesture )
// Note: Properties are registered separately below,
-DALI_SIGNAL_REGISTRATION( Control, "key-event", SIGNAL_KEY_EVENT )
-DALI_SIGNAL_REGISTRATION( Control, "tapped", SIGNAL_TAPPED )
-DALI_SIGNAL_REGISTRATION( Control, "panned", SIGNAL_PANNED )
-DALI_SIGNAL_REGISTRATION( Control, "pinched", SIGNAL_PINCHED )
-DALI_SIGNAL_REGISTRATION( Control, "long-pressed", SIGNAL_LONG_PRESSED )
+DALI_SIGNAL_REGISTRATION( Control, "key-event", SIGNAL_KEY_EVENT )
+DALI_SIGNAL_REGISTRATION( Control, "key-input-focus-gained", SIGNAL_KEY_INPUT_FOCUS_GAINED )
+DALI_SIGNAL_REGISTRATION( Control, "key-input-focus-lost", SIGNAL_KEY_INPUT_FOCUS_LOST )
+DALI_SIGNAL_REGISTRATION( Control, "tapped", SIGNAL_TAPPED )
+DALI_SIGNAL_REGISTRATION( Control, "panned", SIGNAL_PANNED )
+DALI_SIGNAL_REGISTRATION( Control, "pinched", SIGNAL_PINCHED )
+DALI_SIGNAL_REGISTRATION( Control, "long-pressed", SIGNAL_LONG_PRESSED )
DALI_ACTION_REGISTRATION( Control, "control-activated", ACTION_CONTROL_ACTIVATED )
Background* mBackground; ///< Only create the background if we use it
Vector3* mStartingPinchScale; ///< The scale when a pinch gesture starts, TODO: consider removing this
Toolkit::Control::KeyEventSignalType mKeyEventSignal;
+ Toolkit::Control::KeyInputFocusSignalType mKeyInputFocusGainedSignal;
+ Toolkit::Control::KeyInputFocusSignalType mKeyInputFocusLostSignal;
// Gesture Detection
PinchGestureDetector mPinchGestureDetector;
{
controlImpl.KeyEventSignal().Connect( tracker, functor );
}
+ else if( 0 == strcmp( signalName.c_str(), SIGNAL_KEY_INPUT_FOCUS_GAINED ) )
+ {
+ controlImpl.KeyInputFocusGainedSignal().Connect( tracker, functor );
+ }
+ else if( 0 == strcmp( signalName.c_str(), SIGNAL_KEY_INPUT_FOCUS_LOST ) )
+ {
+ controlImpl.KeyInputFocusLostSignal().Connect( tracker, functor );
+ }
else if( 0 == strcmp( signalName.c_str(), SIGNAL_TAPPED ) )
{
controlImpl.EnableGestureDetection( Gesture::Tap );
return mImpl->mKeyEventSignal;
}
+Toolkit::Control::KeyInputFocusSignalType& Control:: KeyInputFocusGainedSignal()
+{
+ return mImpl->mKeyInputFocusGainedSignal;
+}
+
+Toolkit::Control::KeyInputFocusSignalType& Control:: KeyInputFocusLostSignal()
+{
+ return mImpl->mKeyInputFocusLostSignal;
+}
+
bool Control::EmitKeyEventSignal( const KeyEvent& event )
{
// Guard against destruction during signal emission
{
}
+void Control::EmitKeyInputFocusSignal( bool focusGained )
+{
+ Dali::Toolkit::Control handle( GetOwner() );
+
+ if ( focusGained )
+ {
+ // signals are allocated dynamically when someone connects
+ if ( !mImpl->mKeyInputFocusGainedSignal.Empty() )
+ {
+ mImpl->mKeyInputFocusGainedSignal.Emit( handle );
+ }
+ }
+ else
+ {
+ // signals are allocated dynamically when someone connects
+ if ( !mImpl->mKeyInputFocusLostSignal.Empty() )
+ {
+ mImpl->mKeyInputFocusLostSignal.Emit( handle );
+ }
+ }
+}
+
void Control::OnKeyInputFocusGained()
{
- // Do Nothing
+ EmitKeyInputFocusSignal( true );
}
void Control::OnKeyInputFocusLost()
{
- // Do Nothing
+ EmitKeyInputFocusSignal( false );
}
void Control::OnSizeAnimation(Animation& animation, const Vector3& targetSize)
/**
* @brief Sets whether this control supports two dimensional
* keyboard navigation (i.e. whether it knows how to handle the
- * keyboardn focus movement between its child actors).
+ * keyboard focus movement between its child actors).
*
* The control doesn't support it by default.
* @param[in] isSupported Whether this control supports two dimensional keyboard navigation.
*/
virtual void OnKeyboardFocusChangeCommitted(Actor commitedFocusableActor);
+ /**
+ * @brief Emits KeyInputFocusGained signal if true else emits KeyInputFocusLost signal
+ *
+ * Should be called last by the control after it acts on the Input Focus change.
+ *
+ * @param[in] focusGained True if gained, False if lost
+ */
+ void EmitKeyInputFocusSignal( bool focusGained );
+
// Actions & Signals
/**
Toolkit::Control::KeyEventSignalType& KeyEventSignal();
/**
+ * @copydoc Dali::Toolkit::Control::KeyInputFocusGainedSignal()
+ */
+ Toolkit::Control::KeyInputFocusSignalType& KeyInputFocusGainedSignal();
+
+ /**
+ * @copydoc Dali::Toolkit::Control::KeyInputFocusLostSignal()
+ */
+ Toolkit::Control::KeyInputFocusSignalType& KeyInputFocusLostSignal();
+
+ /**
* @brief Called by the KeyInputFocusManager to emit key event signals.
*
* @param[in] event The key event.
return GetImplementation().KeyEventSignal();
}
+Control::KeyInputFocusSignalType& Control::KeyInputFocusGainedSignal()
+{
+ return GetImplementation().KeyInputFocusGainedSignal();
+}
+
+Control::KeyInputFocusSignalType& Control::KeyInputFocusLostSignal()
+{
+ return GetImplementation().KeyInputFocusLostSignal();
+}
+
Control::Control(Internal::Control& implementation)
: CustomActor(implementation)
{
* @see Internal::Control
*
* Signals
- * | %Signal Name | Method |
- * |-------------------|-----------------------------------------------------|
- * | key-event | @ref KeyEventSignal() |
- * | tapped | @ref GetTapGestureDetector().DetectedSignal() |
- * | panned | @ref GetPanGestureDetector().DetectedSignal() |
- * | pinched | @ref GetPinchGestureDetector().DetectedSignal() |
- * | long-pressed | @ref GetLongPressGestureDetector().DetectedSignal() |
+ * | %Signal Name | Method |
+ * |------------------------|-----------------------------------------------------|
+ * | key-event | @ref KeyEventSignal() |
+ * | key-input-focus-gained | @ref KeyInputFocusGainedSignal() |
+ * | key-input-focus-lost | @ref KeyInputFocusLostSignal() |
+ * | tapped | @ref GetTapGestureDetector().DetectedSignal() |
+ * | panned | @ref GetPanGestureDetector().DetectedSignal() |
+ * | pinched | @ref GetPinchGestureDetector().DetectedSignal() |
+ * | long-pressed | @ref GetLongPressGestureDetector().DetectedSignal() |
*
* Actions
* | %Action Name | %Control method called |
/// @brief Key Event signal type;
typedef Signal<bool ( Control, const KeyEvent& ) > KeyEventSignalType;
+ /// @brief Key InputFocusType signal type;
+ typedef Signal<void ( Control ) > KeyInputFocusSignalType;
+
public: // Creation & Destruction
/**
* @code
* bool YourCallbackName(Control control, const KeyEvent& event);
* @endcode
- * The return value of True, indicates that the touch event should be consumed.
- * Otherwise the signal will be emitted on the next sensitive parent of the actor.
+ * The return value of True, indicates that the event should be consumed.
+ * Otherwise the signal will be emitted on the next parent of the actor.
* @pre The Control has been initialized.
* @return The signal to connect to.
*/
KeyEventSignalType& KeyEventSignal();
+ /**
+ * @brief This signal is emitted when the control gets Key Input Focus
+ *
+ * A callback of the following type may be connected:
+ * @code
+ * bool YourCallbackName( Control control );
+ * @endcode
+ * The return value of True, indicates that the event should be consumed.
+ * Otherwise the signal will be emitted on the next parent of the actor.
+ * @pre The Control has been initialized.
+ * @return The signal to connect to.
+ */
+ KeyInputFocusSignalType& KeyInputFocusGainedSignal();
+
+ /**
+ * @brief This signal is emitted when the control loses Key Input Focus
+ * which could be due to it being gained by another Control or Actor or just cleared from
+ * this control as no longer required.
+ *
+ * A callback of the following type may be connected:
+ * @code
+ * bool YourCallbackName( Control control );
+ * @endcode
+ * The return value of True, indicates that the event should be consumed.
+ * Otherwise the signal will be emitted on the next parent of the actor.
+ * @pre The Control has been initialized.
+ * @return The signal to connect to.
+ */
+ KeyInputFocusSignalType& KeyInputFocusLostSignal();
+
public: // Intended for control developers
/**