Note that there are some explanatory texts on larger screens.

plurals
  1. POChange text selection color for TextArea in Flex 4 for programmatic selection
    primarykey
    data
    text
    <p>I am using a Flex 4 spark TextArea and I implemented a search field. I use the following code to highlight the searched text in the TextArea: </p> <pre><code>private function findAndHighlightText():void { var text:String = findTextInput.text; var beginIndex:int = scriptSourceTextArea.text.indexOf( text, m_lastFoundIndex ); if (beginIndex == -1 &amp;&amp; m_lastFoundIndex &gt; 0) { // We are at the end, search back from the begin Alert.show( resourceManager.getString( 'groovyresources', 'search.at.end' ), resourceManager.getString( 'groovyresources', 'find' ) ); m_lastFoundIndex = 0; beginIndex = scriptSourceTextArea.text.indexOf( text, m_lastFoundIndex ); } if (beginIndex != -1) { var endIndex:int = beginIndex + text.length; m_lastFoundIndex = endIndex; scriptSourceTextArea.selectRange( beginIndex, endIndex ); scriptSourceTextArea.scrollToRange( beginIndex ); } else { Alert.show( resourceManager.getString( 'groovyresources', 'search.not.found', [text] ), resourceManager.getString( 'groovyresources', 'find' ) ); } } </code></pre> <p>The most important is the method <code>selectRange</code> on the TextArea. This highlights the text in the TextArea, but I would like to use a different color. </p> <p>I can change the highlight color for manual selection by applying the CSS style <code>focused-text-selection-color</code> (See <a href="http://www.kirupa.com/forum/showthread.php?354479-Change-highlight-color-for-text-fields" rel="nofollow">http://www.kirupa.com/forum/showthread.php?354479-Change-highlight-color-for-text-fields</a>), but this does <em>not</em> change the color for the programmatic selection.</p> <p>UPDATE: The color does not change for the programmatic selection because the TextArea does not have the focus at that moment. So I need to find the <em>unfocused</em> selection color CSS name.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload