<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Preventing specific items from being selected in a Flex Tree control</title>
	<atom:link href="http://blog.flexexamples.com/2008/01/16/preventing-specific-items-from-being-selected-in-a-flex-tree-control/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.flexexamples.com/2008/01/16/preventing-specific-items-from-being-selected-in-a-flex-tree-control/</link>
	<description>Just a bunch of Adobe Flex Examples</description>
	<lastBuildDate>Sun, 12 Feb 2012 19:26:49 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: sun</title>
		<link>http://blog.flexexamples.com/2008/01/16/preventing-specific-items-from-being-selected-in-a-flex-tree-control/comment-page-1/#comment-8656</link>
		<dc:creator>sun</dc:creator>
		<pubDate>Fri, 10 Dec 2010 03:11:48 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2008/01/16/preventing-specific-items-from-being-selected-in-a-flex-tree-control/#comment-8656</guid>
		<description>If i don&#039;t want the tree change its selecteditem when i key in any of the key, is it possible?</description>
		<content:encoded><![CDATA[<p>If i don&#8217;t want the tree change its selecteditem when i key in any of the key, is it possible?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://blog.flexexamples.com/2008/01/16/preventing-specific-items-from-being-selected-in-a-flex-tree-control/comment-page-1/#comment-6985</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Fri, 12 Feb 2010 01:23:41 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2008/01/16/preventing-specific-items-from-being-selected-in-a-flex-tree-control/#comment-6985</guid>
		<description>@harley
type:  (event.currentTarget as Tree).
bingo - auto complete</description>
		<content:encoded><![CDATA[<p>@harley<br />
type:  (event.currentTarget as Tree).<br />
bingo &#8211; auto complete</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter deHaan</title>
		<link>http://blog.flexexamples.com/2008/01/16/preventing-specific-items-from-being-selected-in-a-flex-tree-control/comment-page-1/#comment-6411</link>
		<dc:creator>Peter deHaan</dc:creator>
		<pubDate>Fri, 20 Nov 2009 02:55:13 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2008/01/16/preventing-specific-items-from-being-selected-in-a-flex-tree-control/#comment-6411</guid>
		<description>@Nicolas,

I&#039;m sure there is a better way, but here&#039;s kind of a brute force method of keeping certain nodes open:
&lt;pre lang=&quot;mxml&quot;&gt;
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;mx:Application xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.events.ListEvent;
            import mx.events.TreeEvent;

            protected var lastScrollPos:uint;

            protected function tr_itemCloseHandler(evt:TreeEvent):void {
                if (evt.item.@lockOpen == true) {
                    var it:Object = tr.openItems;
                    it.push(evt.item);
                    tr.openItems = it;
                    // scroll back to locked item
                    callLater(correctScrollPos);
                }
            }

            protected function correctScrollPos():void {
                tr.verticalScrollPosition = lastScrollPos;
            }

            protected function tr_itemRollOverHandler(evt:ListEvent):void  {
                lastScrollPos = tr.verticalScrollPosition;
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:XMLList id=&quot;dp&quot; xmlns=&quot;&quot;&gt;
        &lt;node label=&quot;root&quot;&gt;
            &lt;node label=&quot;One&quot; /&gt;
            &lt;node label=&quot;Two&quot; /&gt;
            &lt;node label=&quot;Three&quot; lockOpen=&quot;false&quot;&gt;
                &lt;node label=&quot;Three.1&quot; /&gt;
                &lt;node label=&quot;Three.2&quot; /&gt;
                &lt;node label=&quot;Three.3&quot; /&gt;
            &lt;/node&gt;
            &lt;node label=&quot;Four&quot; /&gt;
            &lt;node label=&quot;Five&quot; /&gt;
            &lt;node label=&quot;Six *&quot; lockOpen=&quot;true&quot;&gt;
                &lt;node label=&quot;Six.1&quot; /&gt;
                &lt;node label=&quot;Six.2&quot; /&gt;
            &lt;/node&gt;
            &lt;node label=&quot;Seven&quot; /&gt;
            &lt;node label=&quot;Eight *&quot; lockOpen=&quot;true&quot;&gt;
                &lt;node label=&quot;Eight.1&quot; /&gt;
                &lt;node label=&quot;Eight.2&quot; /&gt;
            &lt;/node&gt;
            &lt;node label=&quot;Nine&quot;&gt;
                &lt;node label=&quot;Nine.1&quot; /&gt;
                &lt;node label=&quot;Nine.2&quot; /&gt;
            &lt;/node&gt;
        &lt;/node&gt;
    &lt;/mx:XMLList&gt;

    &lt;mx:Tree id=&quot;tr&quot;
             dataProvider=&quot;{dp}&quot;
             labelField=&quot;@label&quot;
             openDuration=&quot;0&quot;
             width=&quot;200&quot;
             itemRollOver=&quot;tr_itemRollOverHandler(event);&quot;
             itemClose=&quot;tr_itemCloseHandler(event);&quot; /&gt;

&lt;/mx:Application&gt; 
&lt;/pre&gt;

Peter</description>
		<content:encoded><![CDATA[<p>@Nicolas,</p>
<p>I&#8217;m sure there is a better way, but here&#8217;s kind of a brute force method of keeping certain nodes open:</p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Application</span> xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #339933;">&lt;mx:Script&gt;</span>
<span style="color: #339933;">        &lt;![CDATA[</span>
<span style="color: #339933;">            import mx.events.ListEvent;</span>
<span style="color: #339933;">            import mx.events.TreeEvent;</span>
&nbsp;
<span style="color: #339933;">            protected var lastScrollPos:uint;</span>
&nbsp;
<span style="color: #339933;">            protected function tr_itemCloseHandler(evt:TreeEvent):void {</span>
<span style="color: #339933;">                if (evt.item.@lockOpen == true) {</span>
<span style="color: #339933;">                    var it:Object = tr.openItems;</span>
<span style="color: #339933;">                    it.push(evt.item);</span>
<span style="color: #339933;">                    tr.openItems = it;</span>
<span style="color: #339933;">                    // scroll back to locked item</span>
<span style="color: #339933;">                    callLater(correctScrollPos);</span>
<span style="color: #339933;">                }</span>
<span style="color: #339933;">            }</span>
&nbsp;
<span style="color: #339933;">            protected function correctScrollPos():void {</span>
<span style="color: #339933;">                tr.verticalScrollPosition = lastScrollPos;</span>
<span style="color: #339933;">            }</span>
&nbsp;
<span style="color: #339933;">            protected function tr_itemRollOverHandler(evt:ListEvent):void  {</span>
<span style="color: #339933;">                lastScrollPos = tr.verticalScrollPosition;</span>
<span style="color: #339933;">            }</span>
<span style="color: #339933;">        ]]&gt;</span>
<span style="color: #339933;">    &lt;/mx:Script&gt;</span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:XMLList</span> id=<span style="color: #ff0000;">&quot;dp&quot;</span> xmlns=<span style="color: #ff0000;">&quot;&quot;</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;">&lt;node label=<span style="color: #ff0000;">&quot;root&quot;</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;">&lt;node label=<span style="color: #ff0000;">&quot;One&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
            <span style="color: #000000;">&lt;node label=<span style="color: #ff0000;">&quot;Two&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
            <span style="color: #000000;">&lt;node label=<span style="color: #ff0000;">&quot;Three&quot;</span> lockOpen=<span style="color: #ff0000;">&quot;false&quot;</span><span style="color: #7400FF;">&gt;</span></span>
                <span style="color: #000000;">&lt;node label=<span style="color: #ff0000;">&quot;Three.1&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;">&lt;node label=<span style="color: #ff0000;">&quot;Three.2&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;">&lt;node label=<span style="color: #ff0000;">&quot;Three.3&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
            <span style="color: #000000;">&lt;/node<span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;">&lt;node label=<span style="color: #ff0000;">&quot;Four&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
            <span style="color: #000000;">&lt;node label=<span style="color: #ff0000;">&quot;Five&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
            <span style="color: #000000;">&lt;node label=<span style="color: #ff0000;">&quot;Six *&quot;</span> lockOpen=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #7400FF;">&gt;</span></span>
                <span style="color: #000000;">&lt;node label=<span style="color: #ff0000;">&quot;Six.1&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;">&lt;node label=<span style="color: #ff0000;">&quot;Six.2&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
            <span style="color: #000000;">&lt;/node<span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;">&lt;node label=<span style="color: #ff0000;">&quot;Seven&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
            <span style="color: #000000;">&lt;node label=<span style="color: #ff0000;">&quot;Eight *&quot;</span> lockOpen=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #7400FF;">&gt;</span></span>
                <span style="color: #000000;">&lt;node label=<span style="color: #ff0000;">&quot;Eight.1&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;">&lt;node label=<span style="color: #ff0000;">&quot;Eight.2&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
            <span style="color: #000000;">&lt;/node<span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;">&lt;node label=<span style="color: #ff0000;">&quot;Nine&quot;</span><span style="color: #7400FF;">&gt;</span></span>
                <span style="color: #000000;">&lt;node label=<span style="color: #ff0000;">&quot;Nine.1&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;">&lt;node label=<span style="color: #ff0000;">&quot;Nine.2&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
            <span style="color: #000000;">&lt;/node<span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;">&lt;/node<span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:XMLList</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Tree</span> id=<span style="color: #ff0000;">&quot;tr&quot;</span></span>
<span style="color: #000000;">             dataProvider=<span style="color: #ff0000;">&quot;{dp}&quot;</span></span>
<span style="color: #000000;">             labelField=<span style="color: #ff0000;">&quot;@label&quot;</span></span>
<span style="color: #000000;">             openDuration=<span style="color: #ff0000;">&quot;0&quot;</span></span>
<span style="color: #000000;">             width=<span style="color: #ff0000;">&quot;200&quot;</span></span>
<span style="color: #000000;">             itemRollOver=<span style="color: #ff0000;">&quot;tr_itemRollOverHandler(event);&quot;</span></span>
<span style="color: #000000;">             itemClose=<span style="color: #ff0000;">&quot;tr_itemCloseHandler(event);&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Application</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p>Peter</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nicolas</title>
		<link>http://blog.flexexamples.com/2008/01/16/preventing-specific-items-from-being-selected-in-a-flex-tree-control/comment-page-1/#comment-6406</link>
		<dc:creator>Nicolas</dc:creator>
		<pubDate>Thu, 19 Nov 2009 23:08:12 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2008/01/16/preventing-specific-items-from-being-selected-in-a-flex-tree-control/#comment-6406</guid>
		<description>Is it possible to lock a Tree component in it&#039;s open or closed position?</description>
		<content:encoded><![CDATA[<p>Is it possible to lock a Tree component in it&#8217;s open or closed position?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Heke</title>
		<link>http://blog.flexexamples.com/2008/01/16/preventing-specific-items-from-being-selected-in-a-flex-tree-control/comment-page-1/#comment-4604</link>
		<dc:creator>Heke</dc:creator>
		<pubDate>Fri, 17 Jul 2009 12:14:57 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2008/01/16/preventing-specific-items-from-being-selected-in-a-flex-tree-control/#comment-4604</guid>
		<description>okay, I give up, can&#039;t use this posting with tags:
mx:Tree id=&quot;myTree&quot;</description>
		<content:encoded><![CDATA[<p>okay, I give up, can&#8217;t use this posting with tags:<br />
mx:Tree id=&#8221;myTree&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Heke</title>
		<link>http://blog.flexexamples.com/2008/01/16/preventing-specific-items-from-being-selected-in-a-flex-tree-control/comment-page-1/#comment-4603</link>
		<dc:creator>Heke</dc:creator>
		<pubDate>Fri, 17 Jul 2009 12:13:44 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2008/01/16/preventing-specific-items-from-being-selected-in-a-flex-tree-control/#comment-4603</guid>
		<description>okay, sorry.. seem it deleted part of code:
&lt;code&gt;


Application.application.myTree.selectedItem
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>okay, sorry.. seem it deleted part of code:<br />
<code></p>
<p>Application.application.myTree.selectedItem<br />
</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Heke</title>
		<link>http://blog.flexexamples.com/2008/01/16/preventing-specific-items-from-being-selected-in-a-flex-tree-control/comment-page-1/#comment-4602</link>
		<dc:creator>Heke</dc:creator>
		<pubDate>Fri, 17 Jul 2009 12:11:13 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2008/01/16/preventing-specific-items-from-being-selected-in-a-flex-tree-control/#comment-4602</guid>
		<description>I&#039;m not sure if I understood your problem, but can&#039;t you just reference to your tree by the Tree&#039;s ID? For example: 


and reference to it by using  for example:
Application.application.myTree.selectedItem

Also the Tree inherits Event called &quot;change&quot; which is dispatched as the selectedItem (or selectedIndex, don&#039;t know what that is) changes. So you could call your function through that event rather than itemClick.

itemClick=&quot;tree_itemClick(event)&quot;
replaced by:
change=&quot;tree_itemClick(event)&quot;</description>
		<content:encoded><![CDATA[<p>I&#8217;m not sure if I understood your problem, but can&#8217;t you just reference to your tree by the Tree&#8217;s ID? For example: </p>
<p>and reference to it by using  for example:<br />
Application.application.myTree.selectedItem</p>
<p>Also the Tree inherits Event called &#8220;change&#8221; which is dispatched as the selectedItem (or selectedIndex, don&#8217;t know what that is) changes. So you could call your function through that event rather than itemClick.</p>
<p>itemClick=&#8221;tree_itemClick(event)&#8221;<br />
replaced by:<br />
change=&#8221;tree_itemClick(event)&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: harley</title>
		<link>http://blog.flexexamples.com/2008/01/16/preventing-specific-items-from-being-selected-in-a-flex-tree-control/comment-page-1/#comment-2311</link>
		<dc:creator>harley</dc:creator>
		<pubDate>Thu, 23 Apr 2009 19:26:34 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2008/01/16/preventing-specific-items-from-being-selected-in-a-flex-tree-control/#comment-2311</guid>
		<description>it works well enough for me.
I do have a question. I am pretty dependent on FB&#039;s auto &quot;code completion&quot; and the event.currentTarget.selectedItem just never would have occured to me since &quot;selecedItem&quot; doesn&#039;t come up. is there away to create the var as a tree item?
something like: var mytreeitem:tree = new tree;  I can&#039;t figure out a simple way to do this.. thanks in advance.</description>
		<content:encoded><![CDATA[<p>it works well enough for me.<br />
I do have a question. I am pretty dependent on FB&#8217;s auto &#8220;code completion&#8221; and the event.currentTarget.selectedItem just never would have occured to me since &#8220;selecedItem&#8221; doesn&#8217;t come up. is there away to create the var as a tree item?<br />
something like: var mytreeitem:tree = new tree;  I can&#8217;t figure out a simple way to do this.. thanks in advance.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel</title>
		<link>http://blog.flexexamples.com/2008/01/16/preventing-specific-items-from-being-selected-in-a-flex-tree-control/comment-page-1/#comment-2310</link>
		<dc:creator>Daniel</dc:creator>
		<pubDate>Mon, 21 Apr 2008 12:34:54 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2008/01/16/preventing-specific-items-from-being-selected-in-a-flex-tree-control/#comment-2310</guid>
		<description>It also doesn&#039;t work if you mouse-down on the item and release outside. Then it still selects...</description>
		<content:encoded><![CDATA[<p>It also doesn&#8217;t work if you mouse-down on the item and release outside. Then it still selects&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hans</title>
		<link>http://blog.flexexamples.com/2008/01/16/preventing-specific-items-from-being-selected-in-a-flex-tree-control/comment-page-1/#comment-2309</link>
		<dc:creator>Hans</dc:creator>
		<pubDate>Thu, 17 Jan 2008 18:47:55 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2008/01/16/preventing-specific-items-from-being-selected-in-a-flex-tree-control/#comment-2309</guid>
		<description>In this example, items can still be selected via keyboard up and down arrows.  The example does correctly prevent navigating to parent and child nodes that are disabled via left and right arrows though.</description>
		<content:encoded><![CDATA[<p>In this example, items can still be selected via keyboard up and down arrows.  The example does correctly prevent navigating to parent and child nodes that are disabled via left and right arrows though.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

