Skip to main content
Inspiring
Mar 25, 2010 8:41 PM UTC
Question

Problem with tabbing out of component

I have a text editor I'm working on, using the Flash IDE component, and I don't know how to pass a configuration to the exisiting textflow to set 'manageTabKey'. Basically what I'm trying to do is insert a tab when you hit tab, insted of tabbing focus to another component.

What am I missing?

Thanks in advance!

-Ted

This topic is closed to new replies. Start a new post to keep the conversation going.

9 replies

Inspiring
Mar 30, 2010 1:21 PM UTC

Okay, my eye is still intact.

I re-downloaded the Flash Component, and took another look (since I just don't have the time right now to re-do things to use the flex swc).

The component source uses this in a setter for 'xmlText'.:

var _textFlow:TextFlow = TextFilter.importToFlow(xml, TextFilter.TEXT_LAYOUT_FORMAT);

It assigns internal default text, or text set with the component inspector. It also assign it if a direct call to it is made, like with loaded external content.

So I added this into that section:

var flowConfig = new Configuration();
flowConfig.manageTabKey = true;
           
var importConfig:ImportExportConfiguration = new ImportExportConfiguration();
importConfig.textFlowConfiguration = flowConfig;
           
var _textFlow:TextFlow = TextFilter.importToFlow(xml, TextFilter.TEXT_LAYOUT_FORMAT, importConfig);

And I got results, they just weren't quite there. I'd get a tab, but then it'd tab out of the component. So I think I'm halfway there.

Any ideas?

Translate
Inspiring
Mar 30, 2010 2:36 PM UTC

okay, kind of hinky but this works:

Added a global click listener and key_up listener.

And a global textFocused var.

I set the Configuration default 'managetabKey' setting to true; I'll sort out how to pass it in the component (without screwing up text imports) later.

private function checkFocus(event:MouseEvent):void
{

     //the component is the grandparent of the Sprite that has focus when you're entering text.

     //this way, the user can stil tab between controls


     if(stage.focus.parent.parent is TextLayout)
     {
          textFocused = true;
     }
     else
     {
          textFocused = false;
     }

}
       
private function checkKeyCode(event:KeyboardEvent):void
{
     if(textFocused&&event.keyCode==9)
     {
          _textFlow.interactionManager.setFocus();
     }
}

Translate
Inspiring
Mar 30, 2010 4:05 PM UTC

Not exactly clear to me but it sounds like you are using the Flash CS4 plugin.  That code is now 18 months old and has not been updated.  I do recall there was a bug with not calling preventDefault on the event when the TAB key is handled.  Best path for you is to move forward and get the latest textLayout.swc from the Flex 4 SDK.  There have been many API changes.

Richard

Translate
Inspiring
Mar 25, 2010 10:39 PM UTC

A custom Configuration needs to be passed to the TextFlow constructor.  The importer supports it as a parameter as well.

Richard

Translate
Inspiring
Mar 26, 2010 9:21 PM UTC

I got that part, i just missed when that happens with the on-stage component. The textflow is declared by

_textFlow = myTextLayout.textflow;

where myTextLayout is the component on stage...

I tried this:

TextFlow.defaultConfiguration.manageTabKey = true;

to no avail...

And i don't see anything about it in the component inspector/editor doohickey...

thanks!

Translate
Inspiring
Mar 26, 2010 10:02 PM UTC

Is this the problem? When a TextFlow is constructed it makes a private copy of either the supplied configuration or the defaultConfiguration

if none is supplied.  You have to make that change *before* you construct the TextFlow.

The idea of the configuration is that it stores things that never change over the life of the TextFlow.

Richard

Translate