X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fbuttons%2Fcheck-box-button-impl.cpp;h=98733ea455dce629be2daabcee049ae7f3e6b075;hb=HEAD;hp=3f4188bfbae83bf3c9b8fe8c23323e654f5e307d;hpb=b8da2e53925b9abb9fa362560069e8ca4aa62f81;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/controls/buttons/check-box-button-impl.cpp b/dali-toolkit/internal/controls/buttons/check-box-button-impl.cpp index 3f4188b..b000325 100644 --- a/dali-toolkit/internal/controls/buttons/check-box-button-impl.cpp +++ b/dali-toolkit/internal/controls/buttons/check-box-button-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2023 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -77,28 +77,35 @@ void CheckBoxButton::OnInitialize() { Button::OnInitialize(); - DevelControl::SetAccessibilityConstructor(Self(), [](Dali::Actor actor) { - return std::unique_ptr( - new AccessibleImpl(actor, Dali::Accessibility::Role::CHECK_BOX)); - }); + Self().SetProperty(DevelControl::Property::ACCESSIBILITY_ROLE, Dali::Accessibility::Role::CHECK_BOX); } -Dali::Accessibility::States CheckBoxButton::AccessibleImpl::CalculateStates() +DevelControl::ControlAccessible* CheckBoxButton::CreateAccessibleObject() { - auto tmp = Button::AccessibleImpl::CalculateStates(); - auto slf = Toolkit::Button::DownCast(self); - if(slf.GetProperty(Toolkit::Button::Property::SELECTED)) - tmp[Dali::Accessibility::State::CHECKED] = true; - return tmp; + return new CheckBoxButton::CheckBoxButtonAccessible(Self()); +} + +Dali::Accessibility::States CheckBoxButton::CheckBoxButtonAccessible::CalculateStates() +{ + auto state = Button::ButtonAccessible::CalculateStates(); + auto self = Toolkit::Button::DownCast(Self()); + if(self.GetProperty(Toolkit::Button::Property::SELECTED)) + { + state[Dali::Accessibility::State::CHECKED] = true; + } + return state; } void CheckBoxButton::OnStateChange(State newState) { // TODO: replace it with OnPropertySet hook once Button::Property::SELECTED will be consistently used - if(Dali::Accessibility::IsUp() && (newState == SELECTED_STATE || newState == UNSELECTED_STATE)) + if(newState == SELECTED_STATE || newState == UNSELECTED_STATE) { - Dali::Accessibility::Accessible::Get(Self())->EmitStateChanged( - Dali::Accessibility::State::CHECKED, newState == SELECTED_STATE ? 1 : 0, 0); + auto* accessible = GetAccessibleObject(); + if(DALI_LIKELY(accessible) && accessible->IsHighlighted()) + { + accessible->EmitStateChanged(Dali::Accessibility::State::CHECKED, newState == SELECTED_STATE ? 1 : 0, 0); + } } }