X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fbuttons%2Fpush-button-impl.cpp;h=2fadac4542e618e3f881e46f4c43513e471e7b38;hp=d09f7811aa23677ca964387e5d21f4965d4d49a5;hb=525bea517c24aade6e79d2720da5fd98d2b45d41;hpb=b0a0aa8215fc520e9d05e5bbd855ef41a0c189bc diff --git a/dali-toolkit/internal/controls/buttons/push-button-impl.cpp b/dali-toolkit/internal/controls/buttons/push-button-impl.cpp index d09f781..2fadac4 100644 --- a/dali-toolkit/internal/controls/buttons/push-button-impl.cpp +++ b/dali-toolkit/internal/controls/buttons/push-button-impl.cpp @@ -99,6 +99,11 @@ void PushButton::OnInitialize() // Push button requires the Leave event. Actor self = Self(); self.SetProperty( Actor::Property::LEAVE_REQUIRED, true ); + + DevelControl::SetAccessibilityConstructor( self, []( Dali::Actor actor ) { + return std::unique_ptr< Dali::Accessibility::Accessible >( + new AccessibleImpl( actor, Dali::Accessibility::Role::PUSH_BUTTON ) ); + } ); } void PushButton::SetIconAlignment( const PushButton::IconAlignment iconAlignment ) @@ -194,6 +199,32 @@ Property::Value PushButton::GetProperty( BaseObject* object, Property::Index pro return value; } +Dali::Accessibility::States PushButton::AccessibleImpl::CalculateStates() +{ + auto tmp = Button::AccessibleImpl::CalculateStates(); + auto slf = Toolkit::Button::DownCast( self ); + tmp[Dali::Accessibility::State::PRESSED] = slf.GetProperty( Toolkit::Button::Property::SELECTED ); + return tmp; +} + +void PushButton::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)) + { + Dali::Accessibility::Accessible::Get(Self())->EmitStateChanged( + Dali::Accessibility::State::PRESSED, newState == SELECTED_STATE ? 1 : 0, 0 + ); + + if (Self().GetProperty(Toolkit::Button::Property::TOGGLABLE)) + { + Dali::Accessibility::Accessible::Get(Self())->EmitStateChanged( + Dali::Accessibility::State::CHECKED, newState == SELECTED_STATE ? 1 : 0, 0 + ); + } + } +} + } // namespace Internal } // namespace Toolkit