[TIMOB-25985] TiAPI: Disable accessibility features on Ti.UI.Button by using AttributedString
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2018-06-21T14:42:45.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 7.5.0 |
Components | Android, iOS |
Labels | android, ios |
Reporter | nicolomonili |
Assignee | Hans Knöchel |
Created | 2018-04-24T08:00:15.000+0000 |
Updated | 2018-09-28T14:23:04.000+0000 |
Description
In my apps i use font-icons for:
- title of buttons
- text of label
*Example:*
var IconicFont = require('IconicFont');
var Icons = new IconicFont({
font: 'listIcons'
});
var btn = Ti.UI.createButton({
height : 50,
width : 50,
color: 'white',
font: {
fontSize: 24,
fontFamily: Icons.fontfamily
},
title: Icons.icon("add"),
textAlign: Ti.UI.TEXT_ALIGNMENT_CENTER,
verticalAlign: Ti.UI.TEXT_VERTICAL_ALIGNMENT_CENTER,
});
If the user active this option _Settings / General / Accessibility / Button Shapes_ , the result is the attached image, an underline on every buttons. I know this is normal, but i would like to know if it was possible to disable this effect.
I tried to active this option *accessibilityHidden*, but without result.
I also thought about using the *attributeString* (with the param [Titanium.UI.ATTRIBUTE_UNDERLINE_STYLE_NONE](http://docs.appcelerator.com/platform/latest/#!/guide/Attributed_Strings-section-src-37538231_AttributedStrings-Underline)), but it's only for _Label_, _TextArea_ or _TextField_.
Info link1: [https://stackoverflow.com/questions/23246543/remove-underline-on-uibutton-in-ios-7](https://stackoverflow.com/questions/23246543/remove-underline-on-uibutton-in-ios-7)
Info link2: [https://developer.apple.com/documentation/uikit/accessibility/uiaccessibility]
Attachments
File | Date | Size |
---|---|---|
Schermata 2018-04-24 alle 09.40.58.png | 2018-04-24T07:43:08.000+0000 | 30161 |
Thanks for raising this! You could expose the native
attributedTitleForState:
API in the SDK and we'd be happy to review it. Moving to TIMOB to track this. *EDIT*: You could try to: 1. Add the following to your TiUIButton.m2. Add the TiUIAttributedString import to the top of the file:
3. Use the new property "attributedString" on the button and pass a well configured Ti.UI.AttributedString instance.
I have to modify this file _Appcelerator Workspace / App Name / build / iphone / Classes / TiUIButton.m_ or this one _User / Library / Application Support / Titanium / mobilesdk / osx / SDK_VERSION / iphone / Classes / TiUIButton.m_ ?
What do you think? ;-) Spoiler: It's the Application Support one, since the build directory is flushed on clean builds.
Yes, i understood it while i was writing. I'm doing some tests ..
I am still not sure it solves it for you. Here is my test case:
How can I enable the underlines as part of accessibility?
_Settings / General / Accessibility / Button Shapes_
Works like a charm :-).
I can confirm, this edit works! By applying _Titanium.UI.ATTRIBUTE_UNDERLINES_STYLE_ it's possible to remove the underline effect added by the accessibility features -> Settings / General / Accessibility / Button Shapes
Cool! I will prepare a pull request and schedule it for 7.3.0.
I was hoping for the next release .. I'll wait, thanks!
The next release is already closed for new features. I have added Android parity as well, so it will be worth waiting.
PR (master): https://github.com/appcelerator/titanium_mobile/pull/10010
[~nicolomonili] The new feature was just added to master (7.4.0), have fun! And it was not moved from 7.3.0 to 7.4.0, but 7.4.0 is basically the new 7.3.0 because 7.2.0 squezzed in for GDPR compliance.
So, it's in the actual 7.3.0.G.A ?
it's in the "new new" 7.4.0, because it was moved out to make place for more critical bugs. The capacity of the quality engineering team is limited, so we wanted to focus on Android in that release.
*Closing ticket.* Verified fix in SDK Version
7.5.0.v20180927102615
Able to disable accessibility features on Ti.UI.Button by usingAttributedString
. *FR Passed (Test Steps)*Created a new Titanium application
Added the test case above by Hans in to the
app.js
Ran the program
Unable to see the button have an underline
Uncommented
Ti.UI.ATTRIBUTE_UNDERLINE_STYLE_NONE
Able to see the underline again
*Test Environment*