This patch allows setting arbitrary attributes on the Accessible level.
Previously this was only possible for Control, and thus application-side
customization of the attributes was unavailable for some other classes (most
notably Layer, which stands in for Window in the AT-SPI tree).
Change-Id: I19f34197dbe9a26d842b1e31b1b23d2a822ac639
return (int)Dali::Toolkit::DevelControl::Property::ACCESSIBILITY_HIGHLIGHTABLE;
}
-SWIGEXPORT int SWIGSTDCALL CSharp_Dali_View_Property_ACCESSIBILITY_ATTRIBUTES_get() {
- return (int)Dali::Toolkit::DevelControl::Property::ACCESSIBILITY_ATTRIBUTES;
-}
-
SWIGEXPORT int SWIGSTDCALL CSharp_Dali_View_Property_ACCESSIBILITY_HIDDEN_get() {
return (int)Dali::Toolkit::DevelControl::Property::ACCESSIBILITY_HIDDEN;
}
return Accessibility::States{states};
}
-Accessibility::Attributes NUIViewAccessible::GetAttributes() const
+void NUIViewAccessible::UpdateAttributes(Accessibility::Attributes& attributes) const
{
- auto attributes = ControlAccessible::GetAttributes();
+ ControlAccessible::UpdateAttributes(attributes);
- CallMethod<Interface::ACCESSIBLE>(mTable->getAttributes, &GetAttributesCallback, &attributes);
+ // Clear attributes previously received from C#. Otherwise we would store all C#
+ // attributes forever, ever if they were removed at the C# end at some point.
+ for(auto& key : mExtraAttributeKeys)
+ {
+ attributes.erase(key);
+ }
+ mExtraAttributeKeys.clear();
+
+ Dali::Accessibility::Attributes extraAttributes;
+ CallMethod<Interface::ACCESSIBLE>(mTable->getAttributes, &GetAttributesCallback, &extraAttributes);
- return attributes;
+ for(auto& extraAttribute : extraAttributes)
+ {
+ attributes.insert_or_assign(extraAttribute.first, extraAttribute.second);
+ mExtraAttributeKeys.emplace(extraAttribute.first);
+ }
}
Property::Index NUIViewAccessible::GetNamePropertyIndex()
#include <dali/devel-api/atspi-interfaces/table-cell.h>
#include <dali/devel-api/atspi-interfaces/text.h>
#include <dali/devel-api/atspi-interfaces/value.h>
+#include <set>
class NUIViewAccessible : public Dali::Toolkit::DevelControl::ControlAccessible,
public virtual Dali::Accessibility::EditableText, // includes Text
Dali::Accessibility::States CalculateStates() override;
- Dali::Accessibility::Attributes GetAttributes() const override;
+ void UpdateAttributes(Dali::Accessibility::Attributes& attributes) const override;
Dali::Property::Index GetNamePropertyIndex() override;
template<Dali::Accessibility::AtspiInterface I, typename R, typename... Args>
R CallMethod(R (*method)(Dali::RefObject*, Args...), Args... args) const;
+ // Set of attribute keys to clean up in UpdateAttributes()
+ mutable std::set<std::string> mExtraAttributeKeys;
+
// Prevents calling C# methods if the View has been disposed
bool mIsDetached = false;
};