Skip to main content
September 21, 2009
Question

setFocus() in InteractionManager is not working?

  • September 21, 2009
  • 2 replies
  • 1056 views

Hi,

I'm trying to implement TLF in out chat application and looks like setFocus() command in InteractionManager has a bug. Here is a code demonstrating it:

var tf:TextFlow = new TextFlow(); // define TextFlow and manager objects

var em:EditManager = new EditManager();

cc = new DisplayObjectContainerController(this, 290, 38);

tf.interactionManager = em;

// compose TextFlow to display

tf.flowComposer.addController(cc);

// add event handler to listen for SelectionEvent

tf.addEventListener(SelectionEvent.SELECTION_CHANGE, selectionHandler);

tf.addEventListener(StatusChangeEvent.INLINE_GRAPHIC_STATUS_CHANGED, graphicStatusChangeHandler);

tf.flowComposer.updateAllContainers(); // update visual representation

// format configuration

var charFormat:CharacterFormat = new CharacterFormat();

charFormat.color = me.colorsArray[me.currColor];

charFormat.fontFamily = "Tahoma, _sans";

charFormat.fontSize = 12;

charFormat.lineHeight = "80%";

tf.hostCharacterFormat = charFormat;

tf.interactionManager.setSelection(0,0);

var pf:ParagraphFormat = new ParagraphFormat();

pf.direction = Direction.RTL;

pf.marginLeft = 2;

pf.marginRight = 3;

pf.marginTop = 5;

IEditManager(tf.interactionManager).applyParagraphFormat(pf);

tf.interactionManager.setFocus();

Actually I see a cursor appears on screen but when I enter the text I am unable to see it. When I'll click with my mouse on the text edit area I can able to enter the text. Tell me what I'm doing wrong. May be the problem is only for text area which is set to RTL user input?

Looks like in the  online rich text editor demo you have exactly the same problem, when you switch text direction from LTR to RTL you can't enter the text until you click with your mouse on the text edit area.

Igor Vasiliev

www.blogtv.com

This topic has been closed for replies.

2 replies

Participant
October 1, 2009

Hi,

Focus gets set when you use tf.interactionManager.setFocus() but the display containers are not updated so as to refresh the display. Also add the statement tf.flowComposer.updateAllContainers() which should even display the cursor at the proper position. In case you want the cursor at the beginning of the the line or at any position use setselection method before setting the focus and updating the display containers.

Hope this is useful.

Adobe Employee
September 23, 2009

You are using a very old version of the framework.  If you could upgrade that would be helpful.  There have been many changes so it will take some time.

Richard

September 24, 2009

The problem with the new one is a file size - when I'm trying to include new TLF library to my project I can't compile it in Flash CS4. Actually I had exactly the same problem with the old one too, but after a short investigation I found that the problem is a large amount of code I have in the existing project and I put several things to the external SWF file and now I'm able to compile and work with it. The new TLF library is twice big then the old one and I'm unable to compile it at all within my project. ;(

Now, regarding the problem I posted here I think you have a runtime problem. Actually I found a solution, I just set focus with 500 milliseconds delay and now it works. Looks like when I make first call you updating something on the screen and can't set it for the first time.

Personally I think the file size of the TLF library is the biggest problem now with Flash CS4. Looks like IDE unable to compile projects with a lot of code inside. I never saw this happens with old Flash CS3. ;(