tableView.AddChild(third, TableView::CellPosition(1, 0));
tableView.AddChild(fourth, TableView::CellPosition(1, 1));
+ focusChangedCallback.Reset();
+
// Set the focus to the first actor
DALI_TEST_CHECK(manager.SetCurrentFocusActor(first) == true);
DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
- DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == second);
+ DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == Actor());
DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == first);
focusChangedCallback.Reset();
tableView.AddChild(third, TableView::CellPosition(1, 0));
tableView.AddChild(fourth, TableView::CellPosition(1, 1));
+ focusChangedCallback.Reset();
+
// Set the focus to the first actor
DALI_TEST_CHECK(manager.SetCurrentFocusActor(first) == true);
DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
- DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == second);
+ DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == Actor());
DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == first);
DALI_TEST_EQUALS(first.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::FOCUSED, TEST_LOCATION);
DALI_TEST_CHECK(manager.GetCurrentFocusActor() == button1);
END_TEST;
-}
\ No newline at end of file
+}
+
+int UtcDaliKeyboardFocusManagerRemoveScene(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline(" UtcDaliKeyboardFocusManagerRemoveScene");
+
+ // Register Type
+ TypeInfo type;
+ type = TypeRegistry::Get().GetTypeInfo("KeyboardFocusManager");
+ DALI_TEST_CHECK(type);
+ BaseHandle handle = type.CreateInstance();
+ DALI_TEST_CHECK(handle);
+
+ KeyboardFocusManager manager = KeyboardFocusManager::Get();
+ DALI_TEST_CHECK(manager);
+
+ bool focusChangedSignalVerified = false;
+ FocusChangedCallback focusChangedCallback(focusChangedSignalVerified);
+ manager.FocusChangedSignal().Connect(&focusChangedCallback, &FocusChangedCallback::Callback);
+
+ // Create the first actor and add it to the stage
+ Actor first = Actor::New();
+ first.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
+ application.GetScene().Add(first);
+
+ // Check that the focus is set on the first actor
+ DALI_TEST_CHECK(manager.SetCurrentFocusActor(first) == true);
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
+ DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
+ DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == Actor());
+ DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == first);
+ focusChangedCallback.Reset();
+
+ // Remove actor from scene
+ application.GetScene().Remove(first);
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor());
+ DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
+ DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == first);
+ DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == Actor());
+ focusChangedCallback.Reset();
+
+ // Add actor to scene
+ application.GetScene().Add(first);
+ DALI_TEST_CHECK(manager.SetCurrentFocusActor(first) == true);
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
+ DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
+ DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == Actor());
+ DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == first);
+ focusChangedCallback.Reset();
+
+ END_TEST;
+}
actor.Add(GetFocusIndicatorActor());
}
+ actor.OffSceneSignal().Connect(mSlotDelegate, &KeyboardFocusManager::OnSceneDisconnection);
+
// Save the current focused actor
mCurrentFocusActor = actor;
}
}
-void KeyboardFocusManager::ClearFocus()
+void KeyboardFocusManager::ClearFocus(Actor actor)
{
- ClearFocusIndicator();
- Actor actor = GetCurrentFocusActor();
if(actor)
{
DALI_LOG_RELEASE_INFO("ClearFocus id:(%d)\n", actor.GetProperty<int32_t>(Dali::Actor::Property::ID));
+ actor.OffSceneSignal().Disconnect(mSlotDelegate, &KeyboardFocusManager::OnSceneDisconnection);
// Send notification for the change of focus actor
if(!mFocusChangedSignal.Empty())
{
mCurrentFocusActor.Reset();
}
-void KeyboardFocusManager::ClearFocusIndicator()
+void KeyboardFocusManager::ClearFocusIndicator(Actor actor)
{
- Actor actor = GetCurrentFocusActor();
if(actor)
{
if(mFocusIndicatorActor)
mIsFocusIndicatorShown = (mAlwaysShowIndicator == ALWAYS_SHOW) ? SHOW : HIDE;
}
+void KeyboardFocusManager::ClearFocus()
+{
+ Actor actor = GetCurrentFocusActor();
+ ClearFocusIndicator(actor);
+ ClearFocus(actor);
+}
+
void KeyboardFocusManager::SetFocusGroupLoop(bool enabled)
{
mFocusGroupLoopEnabled = enabled;
// If mClearFocusOnTouch is false, do not clear the focus indicator even if user touch the screen.
if(mClearFocusOnTouch)
{
- ClearFocusIndicator();
+ ClearFocusIndicator(GetCurrentFocusActor());
}
// If KEYBOARD_FOCUSABLE and TOUCH_FOCUSABLE is true, set focus actor
mFocusFinderRootActor.Reset();
}
+void KeyboardFocusManager::OnSceneDisconnection(Dali::Actor actor)
+{
+ if(actor && actor == mCurrentFocusActor.GetHandle())
+ {
+ DALI_LOG_RELEASE_INFO("ClearFocus due to actor id:(%d) removed from scene\n", actor.GetProperty<int32_t>(Dali::Actor::Property::ID));
+ ClearFocusIndicator(actor);
+ ClearFocus(actor);
+ }
+}
+
} // namespace Internal
} // namespace Toolkit
*/
bool EmitCustomWheelSignals(Actor actor, const WheelEvent& event);
+ /**
+ * Clear the focus actor
+ * @param[in] actor Actor to be cleared of focus
+ */
+ void ClearFocus(Actor actor);
+
/**
* Clear the focus indicator actor.
+ * @param[in] actor Actor to be cleared of focus indicator.
*/
- void ClearFocusIndicator();
+ void ClearFocusIndicator(Actor actor);
/**
* Gets the current native window id
*/
uint32_t GetCurrentWindowId() const;
+ /**
+ * Signal handler called when a focused actor is removed from Scene.
+ * @param[in] actor The actor removed from the scene.
+ */
+ void OnSceneDisconnection(Dali::Actor actor);
+
private:
// Undefined
KeyboardFocusManager(const KeyboardFocusManager&);