<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.2.1" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: Disabling keyboard navigation on the Accordion container in Flex</title>
	<link>http://blog.flexexamples.com/2008/06/10/disabling-keyboard-navigation-on-the-accordion-container-in-flex/</link>
	<description>A bunch of examples for Adobe Flex and ActionScript</description>
	<pubDate>Thu, 08 Jan 2009 12:19:05 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2.1</generator>

	<item>
		<title>By: yon</title>
		<link>http://blog.flexexamples.com/2008/06/10/disabling-keyboard-navigation-on-the-accordion-container-in-flex/#comment-17089</link>
		<author>yon</author>
		<pubDate>Mon, 01 Dec 2008 19:54:10 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2008/06/10/disabling-keyboard-navigation-on-the-accordion-container-in-flex/#comment-17089</guid>
		<description>I created a blog, i plan to post articles about flex and coding as soon as i have some free time
By now i have the code i posted above (without errors, since i didnt parsed it to be digested by the postin machine in here..) with a working example.
You can read it here
http://faithoncode.wordpress.com/2008/11/11/flex-accordionheaders/

Regards</description>
		<content:encoded><![CDATA[<p>I created a blog, i plan to post articles about flex and coding as soon as i have some free time<br />
By now i have the code i posted above (without errors, since i didnt parsed it to be digested by the postin machine in here..) with a working example.<br />
You can read it here<br />
<a href="http://faithoncode.wordpress.com/2008/11/11/flex-accordionheaders/" rel="nofollow">http://faithoncode.wordpress.com/2008/11/11/flex-accordionheaders/</a></p>
<p>Regards</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: thomary</title>
		<link>http://blog.flexexamples.com/2008/06/10/disabling-keyboard-navigation-on-the-accordion-container-in-flex/#comment-16612</link>
		<author>thomary</author>
		<pubDate>Fri, 07 Nov 2008 17:56:59 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2008/06/10/disabling-keyboard-navigation-on-the-accordion-container-in-flex/#comment-16612</guid>
		<description>I used a work around.   added a blank page and defaulted to that one.

Thanks for all these pages.  
I found a lot of useful pages here.</description>
		<content:encoded><![CDATA[<p>I used a work around.   added a blank page and defaulted to that one.</p>
<p>Thanks for all these pages.<br />
I found a lot of useful pages here.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: thomary</title>
		<link>http://blog.flexexamples.com/2008/06/10/disabling-keyboard-navigation-on-the-accordion-container-in-flex/#comment-16610</link>
		<author>thomary</author>
		<pubDate>Fri, 07 Nov 2008 16:03:52 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2008/06/10/disabling-keyboard-navigation-on-the-accordion-container-in-flex/#comment-16610</guid>
		<description>I was looking for code to open myform with the accordion totally collapsed.  In other words, all accordion pages are not open.  The default is to have the first page opened.  

I looked through Adobe forums, adobe class for accordion and around the internet.  
I think I need something like:
 my_acc.getChildAt(my_acc.numChildren -1);

I tried:

cfformitem type="script"
function formOnLoad(){
var theChild_obj:Object = {};
var theChild_obj:Object = info.getChildAt(info.numChildren -1);
}
/cfformitem
But this did not work. 
I am using CFusion MX 7 with cfform format="Flash"  
Any help would be greatly appreciated. 
Thanks, Thomary</description>
		<content:encoded><![CDATA[<p>I was looking for code to open myform with the accordion totally collapsed.  In other words, all accordion pages are not open.  The default is to have the first page opened.  </p>
<p>I looked through Adobe forums, adobe class for accordion and around the internet.<br />
I think I need something like:<br />
 my_acc.getChildAt(my_acc.numChildren -1);</p>
<p>I tried:</p>
<p>cfformitem type=&#8221;script&#8221;<br />
function formOnLoad(){<br />
var theChild_obj:Object = {};<br />
var theChild_obj:Object = info.getChildAt(info.numChildren -1);<br />
}<br />
/cfformitem<br />
But this did not work.<br />
I am using CFusion MX 7 with cfform format=&#8221;Flash&#8221;<br />
Any help would be greatly appreciated.<br />
Thanks, Thomary</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Yon</title>
		<link>http://blog.flexexamples.com/2008/06/10/disabling-keyboard-navigation-on-the-accordion-container-in-flex/#comment-16083</link>
		<author>Yon</author>
		<pubDate>Wed, 08 Oct 2008 21:17:12 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2008/06/10/disabling-keyboard-navigation-on-the-accordion-container-in-flex/#comment-16083</guid>
		<description>I made an accordion some time ago on kind of this line, I extended the accordion, however i didnt wanted to disable keyboard, just wanted to disable navigation to disabled headers, but still be able to use both mouse and keyboard to navigate.

I use a recursive function to achieve this, however it acts funny if u disable all headers (but why disable all headers anyways..)
&lt;pre class="code"&gt;
package renders {
	import mx.events.IndexChangedEvent;
	import flash.events.KeyboardEvent;
	import mx.containers.Accordion;
	import mx.core.mx_internal;
	import flash.events.Event;
	import flash.ui.Keyboard;
	
	
	public class PracticalAccordion extends Accordion {
		private var _focusedIndex:int = -1;
		
		public function PracticalAccordion() {
			super();
		}
		
	    private function drawHeaderFocus(headerIndex:int, isFocused:Boolean):void {
	        if (headerIndex != -1)
	            getHeaderAt(headerIndex).drawFocus(isFocused);
	    }
		
        override protected function keyDownHandler(event:KeyboardEvent):void {
	        if (event.target != this)
	            return;
	
	        var prevValue:int = selectedIndex;
	        if(event.keyCode != Keyboard.SPACE &#38;&#38; event.keyCode != Keyboard.ENTER)
	        	drawHeaderFocus(_focusedIndex, false);
	        getIndexPlus(event, 0, prevValue);
	        if(event.keyCode != Keyboard.SPACE &#38;&#38; event.keyCode != Keyboard.ENTER)
                drawHeaderFocus(_focusedIndex, true);
            event.stopPropagation();
            if(event.keyCode != Keyboard.DOWN &#38;&#38; event.keyCode != Keyboard.UP &#38;&#38; event.keyCode != Keyboard.LEFT &#38;&#38; event.keyCode != Keyboard.RIGHT)
            	dispatchChangeEvent(prevValue, selectedIndex, event);
        }
        
        private function getIndexPlus (event:KeyboardEvent, loop:int, prevValue:int):void {
	        switch (event.keyCode) {
	            case Keyboard.PAGE_DOWN: {
	                _focusedIndex = selectedIndex = (selectedIndex  0 ? selectedIndex - 1 : numChildren - 1);
	                break;
	            }
	            case Keyboard.HOME: {
	                _focusedIndex = selectedIndex = 0;
	                break;
	            }
	            case Keyboard.END: {
	                _focusedIndex = selectedIndex = numChildren - 1;
	                break;
	            }
	            case Keyboard.DOWN:
	            case Keyboard.RIGHT: {
	                _focusedIndex = (_focusedIndex  0 ? _focusedIndex - 1 : numChildren - 1);
	                break;
	            }
	            case Keyboard.SPACE:
	            case Keyboard.ENTER: {
	                if (_focusedIndex != selectedIndex) {
	                    selectedIndex = _focusedIndex;
	                }
	                break;
	            }
	        }

          if (_focusedIndex != selectedIndex) {
            	if(!getHeaderAt(selectedIndex).enabled &#124;&#124; !getHeaderAt(_focusedIndex).enabled)
            		if(loop &#60;= numChildren)
            			getIndexPlus(event, loop + 1, prevValue);
/*             		else {
            			_focusedIndex = prevValue;
            			set selectedIndex(prevValue);
            		} */
           	} else
	           	if(!getHeaderAt(selectedIndex).enabled)
	           		if(loop &#60;= numChildren)
	            		getIndexPlus(event, loop + 1, prevValue);
/* 					else {
            			_focusedIndex = prevValue;
            			set selectedIndex(prevValue)
     				} */
        }
        
	    private function dispatchChangeEvent(oldIndex:int,
	                                         newIndex:int,
	                                         cause:Event = null):void {
	        var indexChangeEvent:IndexChangedEvent =
	            new IndexChangedEvent(IndexChangedEvent.CHANGE);
	        indexChangeEvent.oldIndex = oldIndex;
	        indexChangeEvent.newIndex = newIndex;
	        indexChangeEvent.relatedObject = getChildAt(newIndex);
	        indexChangeEvent.triggerEvent = cause;
	        dispatchEvent(indexChangeEvent);
	    }
	}
}
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>I made an accordion some time ago on kind of this line, I extended the accordion, however i didnt wanted to disable keyboard, just wanted to disable navigation to disabled headers, but still be able to use both mouse and keyboard to navigate.</p>
<p>I use a recursive function to achieve this, however it acts funny if u disable all headers (but why disable all headers anyways..)</p>
<pre class="code">
package renders {
	import mx.events.IndexChangedEvent;
	import flash.events.KeyboardEvent;
	import mx.containers.Accordion;
	import mx.core.mx_internal;
	import flash.events.Event;
	import flash.ui.Keyboard;

	public class PracticalAccordion extends Accordion {
		private var _focusedIndex:int = -1;

		public function PracticalAccordion() {
			super();
		}

	    private function drawHeaderFocus(headerIndex:int, isFocused:Boolean):void {
	        if (headerIndex != -1)
	            getHeaderAt(headerIndex).drawFocus(isFocused);
	    }

        override protected function keyDownHandler(event:KeyboardEvent):void {
	        if (event.target != this)
	            return;

	        var prevValue:int = selectedIndex;
	        if(event.keyCode != Keyboard.SPACE &amp;&amp; event.keyCode != Keyboard.ENTER)
	        	drawHeaderFocus(_focusedIndex, false);
	        getIndexPlus(event, 0, prevValue);
	        if(event.keyCode != Keyboard.SPACE &amp;&amp; event.keyCode != Keyboard.ENTER)
                drawHeaderFocus(_focusedIndex, true);
            event.stopPropagation();
            if(event.keyCode != Keyboard.DOWN &amp;&amp; event.keyCode != Keyboard.UP &amp;&amp; event.keyCode != Keyboard.LEFT &amp;&amp; event.keyCode != Keyboard.RIGHT)
            	dispatchChangeEvent(prevValue, selectedIndex, event);
        }

        private function getIndexPlus (event:KeyboardEvent, loop:int, prevValue:int):void {
	        switch (event.keyCode) {
	            case Keyboard.PAGE_DOWN: {
	                _focusedIndex = selectedIndex = (selectedIndex  0 ? selectedIndex - 1 : numChildren - 1);
	                break;
	            }
	            case Keyboard.HOME: {
	                _focusedIndex = selectedIndex = 0;
	                break;
	            }
	            case Keyboard.END: {
	                _focusedIndex = selectedIndex = numChildren - 1;
	                break;
	            }
	            case Keyboard.DOWN:
	            case Keyboard.RIGHT: {
	                _focusedIndex = (_focusedIndex  0 ? _focusedIndex - 1 : numChildren - 1);
	                break;
	            }
	            case Keyboard.SPACE:
	            case Keyboard.ENTER: {
	                if (_focusedIndex != selectedIndex) {
	                    selectedIndex = _focusedIndex;
	                }
	                break;
	            }
	        }

          if (_focusedIndex != selectedIndex) {
            	if(!getHeaderAt(selectedIndex).enabled || !getHeaderAt(_focusedIndex).enabled)
            		if(loop &lt;= numChildren)
            			getIndexPlus(event, loop + 1, prevValue);
/*             		else {
            			_focusedIndex = prevValue;
            			set selectedIndex(prevValue);
            		} */
           	} else
	           	if(!getHeaderAt(selectedIndex).enabled)
	           		if(loop &lt;= numChildren)
	            		getIndexPlus(event, loop + 1, prevValue);
/* 					else {
            			_focusedIndex = prevValue;
            			set selectedIndex(prevValue)
     				} */
        }

	    private function dispatchChangeEvent(oldIndex:int,
	                                         newIndex:int,
	                                         cause:Event = null):void {
	        var indexChangeEvent:IndexChangedEvent =
	            new IndexChangedEvent(IndexChangedEvent.CHANGE);
	        indexChangeEvent.oldIndex = oldIndex;
	        indexChangeEvent.newIndex = newIndex;
	        indexChangeEvent.relatedObject = getChildAt(newIndex);
	        indexChangeEvent.triggerEvent = cause;
	        dispatchEvent(indexChangeEvent);
	    }
	}
}
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nick</title>
		<link>http://blog.flexexamples.com/2008/06/10/disabling-keyboard-navigation-on-the-accordion-container-in-flex/#comment-13463</link>
		<author>Nick</author>
		<pubDate>Mon, 16 Jun 2008 21:01:45 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2008/06/10/disabling-keyboard-navigation-on-the-accordion-container-in-flex/#comment-13463</guid>
		<description>Hey Peter,

Just wanted to say thank you again! This worked out perfectly for what I needed it for. 

Thanks,

- Nick</description>
		<content:encoded><![CDATA[<p>Hey Peter,</p>
<p>Just wanted to say thank you again! This worked out perfectly for what I needed it for. </p>
<p>Thanks,</p>
<p>- Nick</p>
]]></content:encoded>
	</item>
</channel>
</rss>
