Merge "Fix ClearHighlight() for custom highlight frames" into devel/master
authorSeoyeon Kim <seoyeon2.kim@samsung.com>
Mon, 22 Mar 2021 00:54:23 +0000 (00:54 +0000)
committerGerrit Code Review <gerrit@review>
Mon, 22 Mar 2021 00:54:23 +0000 (00:54 +0000)
dali-toolkit/devel-api/controls/accessible-impl.cpp
dali-toolkit/devel-api/controls/accessible-impl.h

index f986bd4..be4735b 100644 (file)
@@ -291,6 +291,9 @@ bool AccessibleImpl::GrabHighlight()
   highlight.SetProperty(Actor::Property::POSITION_Z, 1.0f);
   highlight.SetProperty(Actor::Property::POSITION, Vector2(0.0f, 0.0f));
 
+  // Remember the highlight actor, so that when the default is changed with
+  // SetHighlightActor(), the currently displayed highlight can still be cleared.
+  currentHighlightActor = highlight;
   EnsureSelfVisible();
   self.Add(highlight);
   SetCurrentlyHighlightedActor(self);
@@ -305,7 +308,8 @@ bool AccessibleImpl::ClearHighlight()
     return false;
   if(GetCurrentlyHighlightedActor() == self)
   {
-    self.Remove(GetHighlightActor());
+    self.Remove(currentHighlightActor.GetHandle());
+    currentHighlightActor = {};
     SetCurrentlyHighlightedActor({});
     EmitHighlighted(false);
     return true;
index feffe75..ff31c1e 100644 (file)
@@ -19,6 +19,7 @@
 // EXTERNAL INCLUDES
 #include <dali/devel-api/adaptor-framework/accessibility-impl.h>
 #include <dali/devel-api/adaptor-framework/accessibility.h>
+#include <dali/public-api/object/weak-handle.h>
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/public-api/dali-toolkit-common.h>
@@ -46,6 +47,7 @@ struct DALI_TOOLKIT_API AccessibleImpl : public virtual Dali::Accessibility::Acc
                                          public virtual Dali::Accessibility::Action
 {
   Dali::Actor self;
+  Dali::WeakHandle<Dali::Actor> currentHighlightActor;
   bool        modal = false, root = false;
 
   AccessibleImpl(Dali::Actor self, Dali::Accessibility::Role role, bool modal = false);