Skip to main content
Inspiring
January 19, 2009
Answered

How do I insert a <br/> in a TextFlow using EditManager on a Sprite

  • January 19, 2009
  • 2 replies
  • 833 views
I am really stuck on how to inject a BreakElement into the TextFlow via the keyboard.
I have been trying to figure out how to modify the SimpleEditor example to insert a <br/> instead of a <p> when I press the <shift>+<enter> keys.

I setup a handler for keyboard events, and I can trap when the appropriate key combination is entered, but I cant actually figure out what "character" to inject into the event stream to generate a <br/>

Any help would be appreciated.

Thanks,
Tim
This topic has been closed for replies.
Correct answer rdermer
Check the documentation for BreakElement - it's the unicode line separator character 0x2028.

2 replies

March 20, 2009
Is possible set configuration to shift + enter to break line?

-Marcos
rdermerCorrect answer
Adobe Employee
January 19, 2009
Check the documentation for BreakElement - it's the unicode line separator character 0x2028.
tpf70Author
Inspiring
January 19, 2009
Thanks for the code, I missed that.

As an aside, implementing this <br/> functionality wasnt as straight forward as I thought it would be. I had to go a roundabout way to get what I was looking for. I have attached my InteractionManager class for the full solution if anyone is interested.

I needed to handle both the textEvent and keyDownEvent handler, while using a member variable to handle the shift key status between the two. I needed to go this route as handling it in the keydownEvent handler alone did not work. I wanted to simply modify the event keycode in the keyDownEventHandler, but this didnt work for some reason.

If anyone wants to try and improve upon this solution, please do, as I am not a fan of using state variables between event handlers (as there seems like an unsafe way).
Thanks,
Tim