<?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: How to stop keyboard event propagation &#8211; Flex / JavaScript?</title>
	<atom:link href="http://www.mehtanirav.com/2008/11/19/how-to-stop-keyboard-event-propagation-flex-javascript/feed" rel="self" type="application/rss+xml" />
	<link>http://www.mehtanirav.com/2008/11/19/how-to-stop-keyboard-event-propagation-flex-javascript</link>
	<description>Nirav Mehta on life, technology and future</description>
	<lastBuildDate>Sun, 14 Mar 2010 02:18:22 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: widged</title>
		<link>http://www.mehtanirav.com/2008/11/19/how-to-stop-keyboard-event-propagation-flex-javascript/comment-page-1#comment-132746</link>
		<dc:creator>widged</dc:creator>
		<pubDate>Mon, 19 Jan 2009 10:35:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.mehtanirav.com/?p=826#comment-132746</guid>
		<description>Thanks for the link. The mxml now displays correctly.

@Nirav. Have you checked BrowserManager and BrowserHistory. I haven&#039;t looked into that but if ctrl-N changes the browserHistory, you should be able to detect it. 
http://www.switchonthecode.com/tutorials/flex-browsermanager-browser-history-and-the-back-button-fun

@JGarrido. You can pass anything from javascript to Flash or from Flash to javascript. You then need to write the javascript code that will perform the required action. I am not sure you can trigger a ctrl-tab action with javascript, though. I never tried.  

Check out the langref for ExternalInterface. For instance, that&#039;s some code that I use to display debugging messages within a division under the flash application.

In Flex:
private static function jsMsg(msg:String):void 
    {
      ExternalInterface.call(&quot;sendToJavaScript&quot;, msg);
    }

On the html page, within a javascript block.
function sendToJavaScript(val) {
	document.getElementById(&#039;flash-debug&#039;).innerHTML += val + &#039;&#039;;
}


To do the opposite and send stuff from javascript to Flash

On the html page, in a script block:
	function callToActionscript(flash, str) {
		getFlashMovie(flash).sendToActionscript(str);
	}
In Flex:
ExternalInterface.addCallback(&quot;sendToActionscript&quot;, callFromJavaScript);

function callFromJavaScript(param):void {
 // do something with param
}</description>
		<content:encoded><![CDATA[<p>Thanks for the link. The mxml now displays correctly.</p>
<p>@Nirav. Have you checked BrowserManager and BrowserHistory. I haven&#8217;t looked into that but if ctrl-N changes the browserHistory, you should be able to detect it.<br />
<a href="http://www.switchonthecode.com/tutorials/flex-browsermanager-browser-history-and-the-back-button-fun" rel="nofollow">http://www.switchonthecode.com/tutorials/flex-browsermanager-browser-history-and-the-back-button-fun</a></p>
<p>@JGarrido. You can pass anything from javascript to Flash or from Flash to javascript. You then need to write the javascript code that will perform the required action. I am not sure you can trigger a ctrl-tab action with javascript, though. I never tried.  </p>
<p>Check out the langref for ExternalInterface. For instance, that&#8217;s some code that I use to display debugging messages within a division under the flash application.</p>
<p>In Flex:<br />
private static function jsMsg(msg:String):void<br />
    {<br />
      ExternalInterface.call(&#8220;sendToJavaScript&#8221;, msg);<br />
    }</p>
<p>On the html page, within a javascript block.<br />
function sendToJavaScript(val) {<br />
	document.getElementById(&#8216;flash-debug&#8217;).innerHTML += val + &#8221;;<br />
}</p>
<p>To do the opposite and send stuff from javascript to Flash</p>
<p>On the html page, in a script block:<br />
	function callToActionscript(flash, str) {<br />
		getFlashMovie(flash).sendToActionscript(str);<br />
	}<br />
In Flex:<br />
ExternalInterface.addCallback(&#8220;sendToActionscript&#8221;, callFromJavaScript);</p>
<p>function callFromJavaScript(param):void {<br />
 // do something with param<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nirav</title>
		<link>http://www.mehtanirav.com/2008/11/19/how-to-stop-keyboard-event-propagation-flex-javascript/comment-page-1#comment-132733</link>
		<dc:creator>Nirav</dc:creator>
		<pubDate>Wed, 31 Dec 2008 06:36:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.mehtanirav.com/?p=826#comment-132733</guid>
		<description>I am not sure if you can pass an even to the browser, but you can certainly call a JavaScript function from Flex and that JavaScript function can do what you want. 

Surely, if you wanted to open tabs - I am not sure if that&#039;s something that will happen.</description>
		<content:encoded><![CDATA[<p>I am not sure if you can pass an even to the browser, but you can certainly call a JavaScript function from Flex and that JavaScript function can do what you want. </p>
<p>Surely, if you wanted to open tabs &#8211; I am not sure if that&#8217;s something that will happen.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JGarrido</title>
		<link>http://www.mehtanirav.com/2008/11/19/how-to-stop-keyboard-event-propagation-flex-javascript/comment-page-1#comment-132731</link>
		<dc:creator>JGarrido</dc:creator>
		<pubDate>Tue, 30 Dec 2008 21:08:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.mehtanirav.com/?p=826#comment-132731</guid>
		<description>I&#039;d be interested in knowing if it&#039;s possible to do the opposite - to allow the keystrokes to pass up to the container. I&#039;m tired of Flash stealing CTRL+T from my browser!</description>
		<content:encoded><![CDATA[<p>I&#8217;d be interested in knowing if it&#8217;s possible to do the opposite &#8211; to allow the keystrokes to pass up to the container. I&#8217;m tired of Flash stealing CTRL+T from my browser!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nirav</title>
		<link>http://www.mehtanirav.com/2008/11/19/how-to-stop-keyboard-event-propagation-flex-javascript/comment-page-1#comment-132684</link>
		<dc:creator>Nirav</dc:creator>
		<pubDate>Thu, 27 Nov 2008 09:56:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.mehtanirav.com/?p=826#comment-132684</guid>
		<description>Hi Johan,

Your issues seems more like Flex focus handling issue. Could you not just focus on the current container? That way, the next time tab gets processed, it will go to the correct new container? 

This is a hack, but similar approach worked for me in AdvancedDataGrid where I wanted to create new rows in the grid when you press enter on the last row.

HTH.

:Nirav</description>
		<content:encoded><![CDATA[<p>Hi Johan,</p>
<p>Your issues seems more like Flex focus handling issue. Could you not just focus on the current container? That way, the next time tab gets processed, it will go to the correct new container? </p>
<p>This is a hack, but similar approach worked for me in AdvancedDataGrid where I wanted to create new rows in the grid when you press enter on the last row.</p>
<p>HTH.</p>
<p>:Nirav</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: johan</title>
		<link>http://www.mehtanirav.com/2008/11/19/how-to-stop-keyboard-event-propagation-flex-javascript/comment-page-1#comment-132683</link>
		<dc:creator>johan</dc:creator>
		<pubDate>Thu, 27 Nov 2008 09:13:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.mehtanirav.com/?p=826#comment-132683</guid>
		<description>I have a similar problem - want to use the Tab key to open a new VBox container element (similar to accordions) if a user enters the Tab key in the last field in the current container.

That is now working, but the Tab is being processed twice: once by my own event handler, then a second time, causing it not to move to the SetFocus field, but one the next.

Did you manage to solve the issue?

thanks, Johan</description>
		<content:encoded><![CDATA[<p>I have a similar problem &#8211; want to use the Tab key to open a new VBox container element (similar to accordions) if a user enters the Tab key in the last field in the current container.</p>
<p>That is now working, but the Tab is being processed twice: once by my own event handler, then a second time, causing it not to move to the SetFocus field, but one the next.</p>
<p>Did you manage to solve the issue?</p>
<p>thanks, Johan</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nirav</title>
		<link>http://www.mehtanirav.com/2008/11/19/how-to-stop-keyboard-event-propagation-flex-javascript/comment-page-1#comment-132674</link>
		<dc:creator>Nirav</dc:creator>
		<pubDate>Wed, 19 Nov 2008 12:57:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.mehtanirav.com/?p=826#comment-132674</guid>
		<description>Update:
I think I am getting closer. Preventing event using JavaScript worked. And I set focus to a textarea in HTML from Flex when I got an accelerator key in Flex. That stopped new window from opening (or other browser/os specific actions). 

Need to clean this up and see if it works always.

Currently, both Flex and HTML textarea have focus, but neither show whatever I type! They&#039;ve become zombies!</description>
		<content:encoded><![CDATA[<p>Update:<br />
I think I am getting closer. Preventing event using JavaScript worked. And I set focus to a textarea in HTML from Flex when I got an accelerator key in Flex. That stopped new window from opening (or other browser/os specific actions). </p>
<p>Need to clean this up and see if it works always.</p>
<p>Currently, both Flex and HTML textarea have focus, but neither show whatever I type! They&#8217;ve become zombies!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
