text input cursor

59 views
Skip to first unread message

dhileepen chakravarthy

unread,
Dec 4, 2008, 2:21:24 AM12/4/08
to Flex India Community
Dear all,

i want to set the focus and the cursor to the text input control after creation complete of login page!
(like you are entering search text directly in Google without clicking the text box)

Thanks in advance
Dhileepen

JAIN JITENDRA

unread,
Dec 4, 2008, 3:47:56 AM12/4/08
to flex_...@googlegroups.com
try callLater(yourComponent.setFocus);
 
Regards,
JJain

 

dhileepen chakravarthy

unread,
Dec 4, 2008, 3:51:32 AM12/4/08
to flex_...@googlegroups.com
Thank you,But i want the cursor blink on the text field like google home page

JAIN JITENDRA

unread,
Dec 4, 2008, 3:54:56 AM12/4/08
to flex_...@googlegroups.com

try callLater(yourComponent.setFocus);
 
Here yourComponent may be a TextInput.
 
Regards,
JJain
 

JavaFlex Rock

unread,
Dec 4, 2008, 4:09:01 AM12/4/08
to Flex India Community
Hi

First focus go on Browser that's y u r not able to set cursor on text
field but u can set focus.
In IE u can do that by java script but i don't know how to do that in
Mozilla.

Thanks,
Pankaj

On Dec 4, 1:54 pm, "JAIN JITENDRA" <warriorofheavens...@gmail.com>
wrote:

dhileepen chakravarthy

unread,
Dec 4, 2008, 4:09:48 AM12/4/08
to flex_...@googlegroups.com
Hi i have using like this its not showing the text cursor on username field

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"    minWidth="990" minHeight="550" fontSize="12" creationComplete="username.setFocus()">
<mx:Panel width="311.89395" height="190.65" layout="absolute"  title="Login"  y="252" x="389">
    <mx:Label x="16" y="21" text="Username :" fontWeight="bold"/>
    <mx:Label x="16" y="58" text="Password :" fontWeight="bold"/>
    <mx:TextInput id="username" x="118" y="19" enter="password.setFocus();"/>
    <mx:TextInput id="password" x="118" y="56" displayAsPassword="true" />
    <mx:Button x="82" y="112" label="Login" />
    <mx:Button x="168" y="112" label="Clear" />
</mx:Panel>
</mx:Application>

JAIN JITENDRA

unread,
Dec 4, 2008, 4:12:08 AM12/4/08
to flex_...@googlegroups.com


creationComplete="callLater(username.setFocus)"
 
Let me know
 
Regards,
JJain

dhileepen chakravarthy

unread,
Dec 4, 2008, 4:14:30 AM12/4/08
to flex_...@googlegroups.com
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"    minWidth="990" minHeight="550" fontSize="12" creationComplete="callLater(username.setFocus)">

<mx:Panel width="311.89395" height="190.65" layout="absolute"  title="Login"  y="252" x="389">
    <mx:Label x="16" y="21" text="Username :" fontWeight="bold"/>
    <mx:Label x="16" y="58" text="Password :" fontWeight="bold"/>
    <mx:TextInput id="username" x="118" y="19" enter="password.setFocus();"/>
    <mx:TextInput id="password" x="118" y="56" displayAsPassword="true" />
    <mx:Button x="82" y="112" label="Login" />
    <mx:Button x="168" y="112" label="Clear" />
</mx:Panel>
</mx:Application>


Not working...

JAIN JITENDRA

unread,
Dec 4, 2008, 4:19:24 AM12/4/08
to flex_...@googlegroups.com

surround with curly brackets
 
creationComplete="{callLater(username.setFocus)}"
Regards,
JJain
 

dhileepen chakravarthy

unread,
Dec 4, 2008, 4:23:40 AM12/4/08
to flex_...@googlegroups.com
Its working but not like google home page..

after entering an url in google then automatically blinks curson on google search text box.


but in my application focus goes into browser and click anywhere in page or tab then only got cursor


let me know you are understood the problem


JavaFlex Rock

unread,
Dec 4, 2008, 5:15:21 AM12/4/08
to Flex India Community
Hi,
I told in above that first focus on browser so it's not get cursor but
can get focus.
Thanks,
Pankaj

On Dec 4, 2:23 pm, "dhileepen chakravarthy" <dhilee...@gmail.com>
wrote:

JAIN JITENDRA

unread,
Dec 4, 2008, 5:35:08 AM12/4/08
to flex_...@googlegroups.com

Add this line to index.template.html
 

<

body scroll="no" onLoad="window.document.${application}.focus();" onkeydown="window.${application}.focus()" >
It will work in IE but not in FF
 
thanks,
 
regards,
JJain
 

Vinod M. Jacob

unread,
Dec 4, 2008, 6:25:20 AM12/4/08
to flex_...@googlegroups.com
when the page load the focus is set to html/browser from Flash player.
The application
doesn't have focus until a user clicks somewhere in the Flex/Flash
application.So you need to write a javascript function to set focus on
the player on when loads.

dhileepen chakravarthy

unread,
Dec 4, 2008, 6:39:13 AM12/4/08
to flex_...@googlegroups.com
JAIN

Its working with IE but its not working with firefox.

How do i fix firefox issue.


David

unread,
Dec 4, 2008, 5:44:32 AM12/4/08
to Flex India Community
Open your swf in the Flash Player, You can get the desired output,
Won't work in browser anyway!.

Regards,
David R

David

unread,
Dec 4, 2008, 7:04:47 AM12/4/08
to Flex India Community
Try SanderGruger's solution (available at the comments) here,

http://axel.cfwebtools.com/index.cfm/2007/6/5/Using-the-FocusManager-in-Flex

Regards,
David R

ganesh

unread,
Dec 4, 2008, 7:42:26 AM12/4/08
to Flex India Community
This works -
call this in the creationComplete of the application -
if(ExternalInterface.available){
ExternalInterface.call("s = function() { document.getElementById
('"+this.id+"').focus(); }");
}
this will get the focus to swf then focus to the required text field
-
focusManager.setFocus(textFieldId);

Ranjit

unread,
Dec 5, 2008, 8:00:40 AM12/5/08
to Flex India Community
Hi Dhileepen,

Here is simple solution:

Goto your project >> html-template folder >> index.template.html >>
open it.

Now edit JavaScript in that as follow:-

PUT THIS : document.DocumentName.focus(); ///Document name is your
flex Ex: - main.mxml file just give main

THIS BECAUSE SETFOCUS() JUST FOCUSES FLASH PLAYER NOT BROWSER TO SET
FOCUS WE CAN ADD ABOVE SINGAL LINE IN FOLLOWING CODE AS i DID.

<script language="JavaScript" type="text/javascript">
<!--
// Version check for the Flash Player that has the ability to start
Player Product Install (6.0r65)
var hasProductInstall = DetectFlashVer(6, 0, 65);

// Version check based upon the values defined in globals
var hasRequestedVersion = DetectFlashVer(requiredMajorVersion,
requiredMinorVersion, requiredRevision);

if ( hasProductInstall && !hasRequestedVersion ) {
// DO NOT MODIFY THE FOLLOWING FOUR LINES
// Location visited after installation is complete if installation is
required
var MMPlayerType = (isIE == true) ? "ActiveX" : "PlugIn";
var MMredirectURL = window.location;
document.title = document.title.slice(0, 47) + " - Flash Player
Installation";
var MMdoctitle = document.title;

AC_FL_RunContent(
"src", "playerProductInstall",
"FlashVars", "MMredirectURL="+MMredirectURL
+'&MMplayerType='+MMPlayerType+'&MMdoctitle='+MMdoctitle+"",
"width", "${width}",
"height", "${height}",
"align", "middle",
"id", "${application}",
"quality", "high",
"bgcolor", "${bgcolor}",
"name", "${application}",
"allowScriptAccess","sameDomain",
"type", "application/x-shockwave-flash",
"pluginspage", "http://www.adobe.com/go/getflashplayer"
);
} else if (hasRequestedVersion) {
// if we've detected an acceptable version
// embed the Flash Content SWF when all tests are passed
AC_FL_RunContent(
"src", "${swf}",
"width", "${width}",
"height", "${height}",
"align", "middle",
"id", "${application}",
"quality", "high",
"bgcolor", "${bgcolor}",
"name", "${application}",
"allowScriptAccess","sameDomain",
"type", "application/x-shockwave-flash",
"pluginspage", "http://www.adobe.com/go/getflashplayer"
);
document.DocumentName.focus(); ///Document name is your flex Ex: -
main.mxml file just give main
} else { // flash is too old or we can't detect the plugin
var alternateContent = 'Alternate HTML content should be placed
here. '
+ 'This content requires the Adobe Flash Player. '
+ '<a href=http://www.adobe.com/go/getflash/>Get Flash</a>';
document.write(alternateContent); // insert non-flash content
}
// -->
</script>

On Dec 4, 4:39 pm, "dhileepen chakravarthy" <dhilee...@gmail.com>
wrote:
Reply all
Reply to author
Forward
0 new messages