I have the following Application tag code in my widget:
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:local="*"
width="100%" height="100%" minWidth="200" minHeight="200" layout="absolute"
creationComplete="init()"
defaultButton="{Send_btn}">
Input field is defined by
<mx:TextInput id="Input_txi" left="10" right="90" bottom="10"/>
Next I have the following at the end of init() method:
Input_txi.setFocus();
Input_txi.selectRange(0,0);
Nevertheless I can’t enter any text just after the page is loaded. I see visually that Input_txi has focus, but keyprints do nothing. I need to click Input_txi before I can enter any text to it.
How to do so that I can start from the very beginning?
EDIT 1
Not worked, neither as in example, nor with jQuery:
<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript" src="jquery-1.7.1.js"></script>
<script type="text/javascript">
// For version detection, set to min. required Flash Player version, or 0 (or 0.0.0), for no version detection.
var swfVersionStr = "${version_major}.${version_minor}.${version_revision}";
// To use express install, set to playerProductInstall.swf, otherwise the empty string.
var xiSwfUrlStr = "${expressInstallSwf}";
var flashvars = {};
var params = {};
params.quality = "high";
params.bgcolor = "${bgcolor}";
params.allowscriptaccess = "sameDomain";
params.allowfullscreen = "true";
var attributes = {};
attributes.id = "${application}";
attributes.name = "${application}";
attributes.align = "middle";
swfobject.embedSWF(
"${swf}.swf", "flashContent",
"${width}", "${height}",
swfVersionStr, xiSwfUrlStr,
flashvars, params, attributes, function(){
/*
var swf = $("#" + attributes.id);
swf.attr("tabindex", 0);
swf.focus();
*/
var f = swfobject.getObjectById(attributes.id);
f.tabIndex = 0;
f.focus();
});
// JavaScript enabled so display the flashContent div in case it is not replaced with a swf object.
swfobject.createCSS("#flashContent", "display:block;text-align:left;");
</script>
When the browser loads the page, the correct text input may have focus inside the SWF, but the SWF does not have focus inside the browser. There are a variety of different approaches for this, and I’ve provided a few links below.
Automatically setting swf object focus
Managing initial swf focus in all browsers