From 28201d8703eab20e089cc517f6187db223512447 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Artur=20=C5=9Awigo=C5=84?= Date: Tue, 16 Mar 2021 14:52:48 +0100 Subject: [PATCH] Fix ClearHighlight() for custom highlight frames ClearHighlight() used GetHighlightActor() to retrieve the currently displayed highlight frame in order to determine which actor to remove from the scene graph. However, it is perfectly legal to SetHighlightActor() while a highlight frame is displayed (takes effect on the next GrabHighlight()), so the currently visible highlight frame handle needs to be saved separately in order to be properly cleared. Change-Id: Ibf41574bac66f9375b72b31d061195d0235621aa --- dali-toolkit/devel-api/controls/accessible-impl.cpp | 6 +++++- dali-toolkit/devel-api/controls/accessible-impl.h | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/dali-toolkit/devel-api/controls/accessible-impl.cpp b/dali-toolkit/devel-api/controls/accessible-impl.cpp index f986bd4..be4735b 100644 --- a/dali-toolkit/devel-api/controls/accessible-impl.cpp +++ b/dali-toolkit/devel-api/controls/accessible-impl.cpp @@ -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; diff --git a/dali-toolkit/devel-api/controls/accessible-impl.h b/dali-toolkit/devel-api/controls/accessible-impl.h index feffe75..ff31c1e 100644 --- a/dali-toolkit/devel-api/controls/accessible-impl.h +++ b/dali-toolkit/devel-api/controls/accessible-impl.h @@ -19,6 +19,7 @@ // EXTERNAL INCLUDES #include #include +#include // INTERNAL INCLUDES #include @@ -46,6 +47,7 @@ struct DALI_TOOLKIT_API AccessibleImpl : public virtual Dali::Accessibility::Acc public virtual Dali::Accessibility::Action { Dali::Actor self; + Dali::WeakHandle currentHighlightActor; bool modal = false, root = false; AccessibleImpl(Dali::Actor self, Dali::Accessibility::Role role, bool modal = false); -- 2.7.4