Skip to main content
Inspiring
March 25, 2010
Question

Problem with tabbing out of component

  • March 25, 2010
  • 2 replies
  • 1479 views

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 has been closed for replies.

2 replies

Inspiring
March 30, 2010

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?

Inspiring
March 30, 2010

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();
     }
}

Adobe Employee
March 30, 2010

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

Adobe Employee
March 25, 2010

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

Richard

Inspiring
March 26, 2010

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!

Adobe Employee
March 26, 2010

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