Adobe Dreamweaver Forums



Last 10 THreads :         Issue with Firefox & Flash Player Installation (Last Post : hhgttg - Replies : 1 - Views : 29 )           »          Up Button Event Handling Problem (Last Post : ABCJARED - Replies : 0 - Views : 1 )           »          audio (Last Post : Captiv8r - Replies : 1 - Views : 2 )           »          Kintana Dummy Page (Last Post : KiahMom - Replies : 4 - Views : 5 )           »          Dreamweaver CS3 Problem on Windows Vista (Last Post : confused_pam - Replies : 14 - Views : 15 )           »          adobe flash player installs but doesn't play (Last Post : kellyg1 - Replies : 1 - Views : 2 )           »          Video Conversion adds slight gray background (Last Post : JRStaf4ord - Replies : 0 - Views : 1 )           »          help getting links in scrolling menu to work (Last Post : NedWebs - Replies : 11 - Views : 12 )           »          left join won't work in query of query? (Last Post : Ian Skinner - Replies : 4 - Views : 5 )           »          Video Conversion adds slight gray background (Last Post : JRStaf4ord - Replies : 1 - Views : 2 )           »         


Home Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
User Info Statistics
Go Back   Adobe Dreamweaver Forums > Other Macromedia/Adobe Products > Flex
 
Tags:



Reply
  #1 (permalink)  
Old 12-04-2008, 10:23 PM
Guddie
 
Posts: n/a
Diggs:
Default TextInput.setFocus() doesn't work

TextInput.setFocus() doesn't seem to work if the TextInput is in a
TabNavigator/ViewStack. Is this a known bug?

I have a TabNavigator in a TitleWindow. There are multiple VBoxes for each
"tab" in the TabNavigator. Each VBox has a Form with a TextInput. When the user
clicks a tab to view a different VBox in the TabNavigator/ViewStack, I want the
TextInput in that VBoxes Form to get the focus and have the cursor placed in
it. Using the valueCommit event of the TabNavigator sets the TextInput's focus,
but doesn't place the cursor. I've tried
"Application.application.systemManager.stage.f ocus = TextInput",
"focusManager.setFocus(TextInput)", and "TextInput.setFocus()" to no avail.

Any workarounds or help is greatly appreciated.

tabnav.addEventListener(FlexEvent.VALUE_COMMIT, changeTabs);

private function changeTabs(event:Event):void
{
//Set focus to TextInput based on which tab is selected
switch (tabnav.selectedIndex)
{
case 0:
{
//Application.application.systemManager.stage.focu s = name1Text;
//focusManager.setFocus(name1Text);
name1Text.setFocus();
break;
}
case 1:
{
//Application.application.systemManager.stage.focu s = addNumText;
//focusManager.setFocus(addNumText);
addNumText.setFocus();
break;
}
case 2:
{
//Application.application.systemManager.stage.focu s = qsText;
//focusManager.setFocus(qsText);
qsText.setFocus();
break;
}
case 3:
{
//Application.application.systemManager.stage.focu s = apn1Text;
//focusManager.setFocus(apn1Text);
apn1Text.setFocus();
break;
}
}
}



Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 12-05-2008, 04:23 PM
Guddie
 
Posts: n/a
Diggs:
Default Re: TextInput.setFocus() doesn't work

It seems all the info on the web about this deals with IE not focusing the Flex app on page load. My issue happens always, not just on page load.
Reply With Quote
  #3 (permalink)  
Old 12-05-2008, 04:53 PM
rtalton
 
Posts: n/a
Diggs:
Default Re: TextInput.setFocus() doesn't work

Do you have more complete code? If you could post that, or better yet, put the app up with view source enabled where we can get our hands on it.
Reply With Quote


  #4 (permalink)  
Old 12-05-2008, 05:14 PM
Guddie
 
Posts: n/a
Diggs:
Default Re: TextInput.setFocus() doesn't work

Full code below. changeTabs() is being fired correctly, but TextInput.setFocus
(and commented out methods) has no effect.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
private function changeTabs(event:Event):void
{
//Set focus to TextInput based on which tab is selected
switch (tabnav.selectedIndex)
{
case 0:
{
//Application.application.systemManager.stage.focu s = name1Text;
//focusManager.setFocus(name1Text);
name1Text.setFocus();
break;
}
case 1:
{
//Application.application.systemManager.stage.focu s = addNumText;
//focusManager.setFocus(addNumText);
addNumText.setFocus();
break;
}
case 2:
{
//Application.application.systemManager.stage.focu s = qsText;
//focusManager.setFocus(qsText);
qsText.setFocus();
break;
}
case 3:
{
//Application.application.systemManager.stage.focu s = apn1Text;
//focusManager.setFocus(apn1Text);
apn1Text.setFocus();
break;
}
}
}
]]>
</mx:Script>
<mx:TitleWindow>
<mx:TabNavigator id="tabnav" valueCommit="changeTabs(event);"
creationPolicy="all">
<mx:VBox label="First">
<mx:Form>
<mx:FormItem>
<mx:TextInput id="name1Text"/>
</mx:FormItem>
</mx:Form>
</mx:VBox>
<mx:VBox label="Second">
<mx:Form>
<mx:FormItem>
<mx:TextInput id="addNumText"/>
</mx:FormItem>
</mx:Form>
</mx:VBox>
<mx:VBox label="Third">
<mx:Form>
<mx:FormItem>
<mx:TextInput id="qsText"/>
</mx:FormItem>
</mx:Form>
</mx:VBox>
<mx:VBox label="Fourth">
<mx:Form>
<mx:FormItem>
<mx:TextInput id="apn1Text"/>
</mx:FormItem>
</mx:Form>
</mx:VBox>
</mx:TabNavigator>
</mx:TitleWindow>
</mx:Application>

Reply With Quote
  #5 (permalink)  
Old 12-05-2008, 08:13 PM
rtalton
 
Posts: n/a
Diggs:
Default Re: TextInput.setFocus() doesn't work

I think you're on the right track concerning the browser focus issue. Here's
how to test it.
Check your project settings:
Project-->Properties-->Flex Compiler
and see if the check box for "Enable integration with browser navigation" is
selected. It could be, by default.
De-select it. You'll get a warning message re: overwriting the HTML wrapper.
Don't worry about it; click OK.
Now run your project and the setFocus() should work.

Reply With Quote
  #6 (permalink)  
Old 12-05-2008, 08:23 PM
Guddie
 
Posts: n/a
Diggs:
Default Re: TextInput.setFocus() doesn't work

"Enable integration with browser navigation" is already deselected. I don't
think this is a browser focus issue, it is a Flex focus issue. The browser
focus issue only occurred when the Flex app loads, and that is resolved using
the below function in the HTML wrapper.

Any other ideas?

function startup()
{
document.${application}.focus(); //Gives Flex app focus in browser
}

Reply With Quote


  #7 (permalink)  
Old 12-05-2008, 08:32 PM
rtalton
 
Posts: n/a
Diggs:
Default Re: TextInput.setFocus() doesn't work

Sorry, but I got sidetracked with the Deep Linking issue.
Change this line: valueCommit="changeTabs(event);"
To this: mouseUp="changeTabs(event);"

The problem here is that the valueCommit causes Flex to move focus back to the
tab. The mouseUp event works because the valueCommit has already fired BEFORE
the mouseUp event, and now you can move it to the textInput. At least that's
what it looks like to me when I trace it.
The focus in your app was just bouncing to the textInput, and back to the tab
again.

Reply With Quote
  #8 (permalink)  
Old 12-05-2008, 08:42 PM
Guddie
 
Posts: n/a
Diggs:
Default Re: TextInput.setFocus() doesn't work

That did it, the one event I didn't try. Thanks a heap!
Reply With Quote
  #9 (permalink)  
Old 12-08-2008, 03:33 PM
Guddie
 
Posts: n/a
Diggs:
Default Re: TextInput.setFocus() doesn't work

Using the mouseUp event to fire the function to set the TextInput focus does
work, but it is fired everytime I click inside the TabNavigator, even if I
click on other form items.

So if I have more than one TextInput in one tab, clicking anywhere on the
form, even in a different TextInput, will make the focus go back to the
TextInput specified. The application code below illustrates this. I only want
the focus to go to the specified TextInput when the user clicks on the tab.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
private function changeTabs(event:Event):void
{
//Set focus to TextInput based on which tab is selected
switch (tabnav.selectedIndex)
{
case 0:
{
name1Text.setFocus();
break;
}
case 1:
{
addNumText.setFocus();
break;
}
case 2:
{
qsText.setFocus();
break;
}
case 3:
{
apn1Text.setFocus();
break;
}
}
}
]]>
</mx:Script>
<mx:TitleWindow>
<mx:TabNavigator id="tabnav" mouseUp="changeTabs(event);"
creationPolicy="all">
<mx:VBox label="First">
<mx:Form>
<mx:FormItem>
<mx:TextInput id="name1Text"/>
<mx:TextInput />
</mx:FormItem>
</mx:Form>
</mx:VBox>
<mx:VBox label="Second">
<mx:Form>
<mx:FormItem>
<mx:TextInput id="addNumText"/>
<mx:TextInput />
</mx:FormItem>
</mx:Form>
</mx:VBox>
<mx:VBox label="Third">
<mx:Form>
<mx:FormItem>
<mx:TextInput id="qsText"/>
<mx:TextInput />
</mx:FormItem>
</mx:Form>
</mx:VBox>
<mx:VBox label="Fourth">
<mx:Form>
<mx:FormItem>
<mx:TextInput id="apn1Text"/>
<mx:TextInput />
</mx:FormItem>
</mx:Form>
</mx:VBox>
</mx:TabNavigator>
</mx:TitleWindow>
</mx:Application>

Reply With Quote


  #10 (permalink)  
Old 12-08-2008, 03:52 PM
rtalton
 
Posts: n/a
Diggs:
Default Re: TextInput.setFocus() doesn't work

The work-around I posted was based on your original code so no, it won't work
with multiple textInputs on the same tab.

I did a little more thinking on this one...
When a user refreshes the browser, the application loses focus, so what you
need to do is look at the application's events, and not the tab navigator.

Here's some code to demonstrate what's happening:
On your application tag, add this:
creationComplete="initApp()"
Then in a script block, add this:
import mx.events.ResizeEvent;
import mx.controls.Alert;

private function initApp():void{
this.addEventListener(ResizeEvent.RESIZE,handleRes izeEvent);
}
private function handleResizeEvent(event:ResizeEvent):void{
Alert.show('focus lost');
}

In the handleResizeEvent function, write code to manipulate focus back to
whatever tab you wish, and you'll have it.

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
All times are GMT. The time now is 09:27 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
Cheap Car Insurance - Compare Motor Insurance
Endsleigh Car Insurance Natwest Car Insurance
More Than Car Insurance Norwich Union Car Insurance
Prudential Car Insurance Zurich Car Insurance
Inactive Reminders By Mished.co.uk