Styling RichText Bullets in Flex - apache-flex

I am developing an iPad app with RichText components. They are working fine on the target devices. However, bullets look less than stellar. Specifcally, I need to increase the space between the bullet and the list item. It's too close and doesn't look good and the design people are not at all pleased with it.
The way the code works is we have an XML file that gets read in, and the contents of the screen are populated from that file. For example, here is a test list I have:
<section id="outro">
<element id="outro">
<copy id="OutroTestCopy" x="50" y="75" width="1200"><![CDATA[
<p fontSize="55" color="#cf7028">List to display</p>
<list fontSize="50" fontWeight="bold" paddingLeft="20">
<listMarkerFormat><ListMarkerFormat paddingRight="300" fontSize="50" fontWeight="bold" afterContent=" " /></listMarkerFormat>
<li>List Reference*<span baselineShift="superscript" alignmentBaseline="ideographicBottom">12</span></li>
<li>List Corp<span baselineShift="superscript" alignmentBaseline="ideographicBottom">®</span></li>
<li>List item</li>
<li>Second list reference<span baselineShift="superscript" alignmentBaseline="ideographicBottom">2</span></li>
</list>
]]></copy>
<footnote><![CDATA[Test footnote]]></footnote>
</element>
</section>
My ActionScript code takes the copy element above and runs it through the TextFlow import. I do this and not use actual TextFlow in the XML file because non-programmers with XML/HTML experience will be editing this file and I wanted to keep the markup as close to HTML as possible, rather than training them to do proper TextFlow:
copyRichText.textFlow = spark.utils.TextFlowUtil.importFromString(copy);
This runs well and I get my bullet list, with superscripts and fancy characters (see below). However, I can't change the spacing between the bullet and the list item text. I just want more space between the ListMarker and the list item. Right now they are too close and looked jammed up, and the design staff are giving me grief about it. I've tried (as you see) some padding and afterContent type attributes to get it to work, but they do nothing. Here is the result of the above, for reference:
Edit to add:
I had previous used these resources for lists in TextFlow:
Adobe's pre-List tags
Adobe's list tags information (TextFlow)
TLF 2.0 Lists Markup with cool PDF print out

Use the beforeContent attribute to add whitespace:
<s:list id="myList" paddingLeft="10" listStylePosition="inside">
<s:listMarkerFormat>
<!-- Note that this example inserts an empty string with &quote; HTML entities. -->
<s:ListMarkerFormat
beforeContent=" "
content="counters(ordered,"",upperRoman)"
afterContent=": "/>
</s:listMarkerFormat>
<s:li>Beginning</s:li>
<s:li>Middle</s:li>
<s:li>End</s:li>
</s:list>
References
Apache Flex API Reference: ListMarkerFormat
Using Text Layout Framework: Using numbered and bulleted lists with TLF-based text controls
Flex 4 Updates For TLF 2.0
Discover the power of Flex and CSS

Related

How to best format thumbnails for accessibility?

I am frequently tasked with displaying a grid of thumbnails for work, such as on a posts/articles page, with each thumbnail linking to a separate post/article, but I have never really been sure of the best way to format these for screen readers/accessibility. More specifically, I have never been sure whether to use the <article> or <figure> tag for this purpose, or neither, or something else entirely. Does anyone know? These are the three methods I am debating between:
<a>
<article>
<img />
<div></div>
</article>
</a>
<a>
<figure>
<img />
<figcaption></figcaption>
</figure>
</a>
<a>
<img />
<div></div>
</a>
The documentation for the article tag says that it "represents a self-contained composition in a document, page, application, or site, which is intended to be independently distributable or reusable". I don't know what that means in this context, but it seems like it could be intended for this purpose, or it could be meant to be used once on the actual article pages and not the overall "articles" list page.
The documentation for the figure tag says that it "represents self-contained content, potentially with an optional caption". It seems like it would work quite well here, except my intuition says that it might be intended more for figures that are inline with the text of articles, so I have my doubts.
The 3rd option is to use neither the article or the figure tag in an effort to just simplify the html as much as possible so that screen readers do not have to look at and interpret as many nested tags.
References:
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/article
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/figure
From an accessibility perspective, I have not found much benefit to using an <article>. On iOS and Mac, Safari incorrectly treats an <article> as a landmark even though the definition of an article role specifically says it isn't.
An article is not a navigational landmark, but may be nested to form a discussion where assistive technologies could pay attention to article nesting to assist the user in following the discussion.
Notice that it says AT could pay attention to the article element but other than the aforementioned treatment as a landmark in Safari, I have not found NVDA, JAWS, or Voiceover to do anything special with an <article>.
If you plan on having a caption below the image, then you could use <figcaption>. It's just a handy way to visually display text below an image. But if the thumbnail doesn't have text below it but rather has a heading or link to the article, then <figcaption> isn't needed.
Your last example, the simplest, is the most common way to code what you want and works just fine for accessibility. I know your code snippets were just minimal code but make sure your <img> uses the alt attribute.
If your image is inside your link (as in your example) and there's other text containing the title of the article within the link, then the image can have an empty alt="" (or even just alt with no value). But if there isn't any visible text in the link, then make sure the image has an appropriate alt attribute value.

Trying to understand aria and accessibility

I'm updating a website, doing an iterative improvement on the accessibility.
I'm using multiple tools to get the pages better: FireFox's accessibility tree viewer; Chrome's lighthouse checker; the "wave" accessibility tool, and I'm trying tenon.io
(sadly, I don't have access to a decent screen reader - nvda is too fast for me to hear, orca seems to read the current line, and I don't have access to JAWS)
So here's what I have:
I have a navigation structure like this:
<nav aria-label="Main navigation">
<section class="desktop-navigation" aria-label="Main Menu">
<ul aria-label="Menu items">
<li>About Example</li>
<li>Documentation</li>
<li>Pricing</li>
<li>Status</li>
<li>Contact us</li>
</ul>
</section>
<section class="main-nav-wrapper" aria-label="Header logos">
<a href="/"><img src="/images/logo_example.svg?v=488a8c6971df396baaa401bb073b4a6b"
class="header-logo" alt="The Example logo" aria-label="Example Logo"/></a>
<div class="site-logos-right" aria-label="Corporate Logos">
<a class="external-link" href="https://www.example.com/" rel="external"><img
src="/images/logo_company.svg?v=98693292e027eca1f27cfc89b68a77d2" class="company-logo"
aria-label="The Company logo" alt="Official logo for Company"/></a>
<a class="external-link" href="https://example.com/department"
rel="external"><img src="/images/logo_department.svg?v=ff0114bb2ebf7eff339341f9554220d0"
class="edina-logo" alt="Official Department logo" aria-label="department logo" /></a>
</div>
</section>
</nav>
..... and this is 100% according the lighthouse, but tenon.io is reporting an issue (multiple times) and I don't understand why:
This element uses multiple strategies to create labels
This element has more than one possible label. The manner in which the
accessible name is calculated for controls uses an algorithm in which
only one of these labelling approaches will win. This means one of
these labels will be ignored by assistive technologies. There should
be only one label provided and the others should be removed.
Examples of items identified:
<nav role="navigation" aria-label="Main navigation">
<section class="desktop-navigation" aria-label="Main Menu">
<ul aria-label="Menu items">
<li><a href="/" aria-label="Return to the home page to read about
(I notice that the W3C site does not label the uls - but then they show as un-named elements in firefox)
I definitely want to label landmarks & sections.... so what's it actually complaing about?
<li>Pricing</li>
.... this is an example of where I want to have a more descriptive label for the element - when scanning the accessibility tree, just having the bare link-text doesn't (to me) read as well as having some context: as a sighted user, I know my eyes have flicked over much of the page, and seen additional text, so subconsciously have some context for the menu items.
My question(s)
How is the accessibility label computed?
Why can't I have a more descriptive label on a link? (lighthouse complains if the alt text doesn't contain the link text... but is happy if it's more than the link text) - or is this tenon.io being over-picky?
The accessible name computation is how accessibility labels are computed.
You're using aria-label too much, and the result may be difficult to listen to or outright confusing for human visitors using assistive technologies.
The first rule of ARIA is don't use ARIA unless you really have to.
It is appropriate to use aria-label on the <nav> and <section> elements. Keep that.
I can't think of any good reason to use aria-label on a <ul> element. I'd recommend removing that.
Using aria-label on anchor elements is normally unnecessary and should be approached with caution. Unless you have a really good reason, you probably shouldn't be presenting different content to visitors using assistive technology.
I would also recommend removing aria-label from your images. This is exactly what alt text is for.
If you really want to use aria-label on anchor elements, WCAG has some guidance:
Per the Accessible Name and Description Computation and the HTML to Platform Accessibility APIs Implementation Guide, the aria-label text will override the text supplied within the link. As such the text supplied will be used instead of the link text by AT. Due to this it is recommended to start the text used in aria-label with the text used within the link. This will allow consistent communication between users.
https://www.w3.org/WAI/WCAG21/Techniques/aria/ARIA8.html#description
Don't give up on NVDA just yet. I also found the default speech settings too fast and difficult to understand. You just need to adjust the settings. The voice can also be changed out for better ones. It takes a bit of work to configure, but in my opinion NVDA is the best free screen reader available today. VoiceOver is also very nice if you have access to Mac/iOS products.

How to set link colors in a RichEditableText component

I've got some text that includes links that I display in a RichEditableText component. How do I change the color of the links from the default blue? I tried the example posted by Peter deHaan but it doesn't work with SDK 4.1. I found a way to do this in MXML, but the text needs to be localizable which means I load it at runtime based on the locale, so I can't just include it inline with the MXML.
To recap: How do I set the link colors for a RichEditableText component that displays HTML that gets loaded at runtime?
Thanks in advance.
Found a way to do this globally, it was in another example on Peter deHaan's site:
http://blog.flexexamples.com/2009/03/17/globally-styling-anchor-tags-on-a-textview-control-in-flex-gumbo/
It's unfortunate you can't set these sorts of things with CSS...
You can also use a nested span tag to colorize your links as you prefer:
<s:RichEditableText id="titleText"
width="100%"
editable="false"
selectable="false"
focusEnabled="false">
<s:textFlow>
<s:TextFlow>
<s:a click="titleText_clickHandler(event)">
<s:span color="#FF0000">
Link's text here
</s:span>
</s:a>
</s:TextFlow>
</s:textFlow>
</s:RichEditableText>

Is element ‘ul’ cannot be nested within element ‘ol’? (i am getting this error from xhtml validator) help pls

<ol style="padding-top:0;">
<li>24 Hour Fitness</li>
<!-- open nested list -->
<ul>
<li>This website would be ideal to use as a reference. The information provided lists references and is also very detailed. You feel confident in what you read in this website as being factual and helpful.</li>
<li>source code – body section</li>
<!-- open nested list -->
<ol type="a">
<li>Don't display unfriendly errors directly to the user.</li>
<li>Used SSL/HTTPS for login and any pages where sensitive data is entered (like credit card info).</li>
<li>Written XHTML/HTML and CSS according to the W3C specifications and make sure they validate. The goal here is to avoid browser quirks modes and as a bonus make it much easier to work with non-standard browsers like screen readers and mobile devices.</li>
<li>Have some system for people to contact you with suggestions and criticism.</li>
</ol>
<!-- closed nested list -->
<li>The website’s goal is to encourage membership at 24 Hour Fitness gyms. This is very easy to determine by both the 24 Hour Fitness banner and the “Membership” banner. The website than provides a number of membership options.
You can locate your local gyms without any problems at all.</li>
<li>The website is quite easy to navigate around. The main reason is because of the six drop down menus at the bottom of the 24 Hour Fitness banner.
These drop down menus remain visible and constant for the majority of the web pages in the site.
For instance, when you click on “Shop” you are sent to a related website so the banner and the drop down menus change.</li>
</ul>
<!-- closed nested list -->
</ol>
The <ul> inside needs to be inside an li, so either make a new li or un-close the first one.
The validator is correct: the only legal elements within a <ul> or <ol> element are <li> elements. If you want to nest lists, put them inside <li> elements.

displaying HTML inside a Flex application

I have some HTML that is generated via a Rich Text Editor outside of my Flex application but would like to display it inside Flex.
The HTML is simple HTML tags, things like styles, anchors, and possibly image tags, is there a control that would let me render this HTML in flex or am I going to have to roll up my sleeves and roll my own?
Any ideas appreciated...Thanks.
If the HTML is really simple, you can display it in a normal label or textarea component, If it is more complex, I'll quote what I answered in this question. The discussion there also has a little more info.
If it is complex HTML and Javascript, one possible way is HTMLComponent, a method that uses an iframe over your flash to make it appear like the HTML is in your app. There are a few downsides to this method however - most of them described in detail at Deitte.com.
If this can move offline, you could use Air (it has an mx:HTML component built in). Deitte.com has a detail of this technique as well.
Check out the documentation on mx.controls.Label and flash.text.TextField (which is what displays the text in a Text or Label control in Flex). The TextField documentation states that
The <img> tag lets you embed external image files (JPEG, GIF, PNG), SWF files, and movie clips inside text fields. Text automatically flows around images you embed in text fields. To use this tag, you must set the text field to be multiline and to wrap text.
Which means that you can display an image in a Text component in Flex by setting its htmlText property to some HTML which contains an <img> tag. You can't use Label, because it is not multiline.
I've noticed that text fields have trouble with properly measuring their heights if the images displayed in them are left or right aligned with text flowing around them (e.g. align="left"). You may have to add some extra spacing below to counter that if you plan to use aligned images.
You will have to use flex iFrame control.
It is not an 100% flash solutions, and combines a bit of js calls but works perfectly for me.
You can grab latest source code from github https://github.com/flex-users/flex-iframe
Here is some sample code from the component author.
<!---
A basic example application showing how to embed a local html page in a Flex application.
#author Alistair Rutherford
-->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:flexiframe="http://code.google.com/p/flex-iframe/"
horizontalAlign="center"
verticalAlign="middle"
viewSourceURL="srcview/index.html">
<!-- Example project presentation -->
<mx:ApplicationControlBar dock="true">
<mx:Text selectable="false">
<mx:htmlText><![CDATA[<font color="#000000" size="12"><b>flex-iframe - Simple html example</b><br>This example shows how to embed a simple Html page in a Flex application.</font>]]></mx:htmlText>
</mx:Text>
</mx:ApplicationControlBar>
<!-- HTML content stored in a String -->
<mx:String id="iFrameHTMLContent">
<![CDATA[
<html>
<head>
<title>About</title>
</head>
<body>
<div>About</div>
<p>Simple HTML Test application. This test app loads a page of html locally.</p>
<div>Credits</div>
<p> </p>
<p>IFrame.as is based on the work of</p>
<ul>
<li>Christophe Coenraets</li>
<li>Brian Deitte</li>
</ul>
</body>
</html>
]]>
</mx:String>
<!-- Example using the 'source' property -->
<mx:Panel title="A simple Html page embedded with the 'source' property"
width="80%"
height="80%">
<flexiframe:IFrame id="iFrameBySource"
width="100%"
height="100%"
source="about.html"/>
</mx:Panel>
<!-- Example using the 'content' property -->
<mx:Panel title="A simple Html page embedded with the 'content' property"
width="80%"
height="80%">
<flexiframe:IFrame id="iFrameByContent"
width="100%"
height="100%"
content="{iFrameHTMLContent}"/>
</mx:Panel>
</mx:Application>
#mmattax
Indeed you can display images in a TextArea component. The approach is not entirely without problems though...

Resources