Skip to main content
Inspiring
Jan 19, 2009 7:33 PM UTC
Answered

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

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 is closed to new replies. Start a new post to keep the conversation going.
rdermerCorrect answer
Inspiring
Jan 19, 2009 8:31 PM UTC
Check the documentation for BreakElement - it's the unicode line separator character 0x2028.

3 replies

Mar 20, 2009 12:46 AM UTC
Is possible set configuration to shift + enter to break line?

-Marcos
Translate
rdermerCorrect answer
Inspiring
Jan 19, 2009 8:31 PM UTC
Check the documentation for BreakElement - it's the unicode line separator character 0x2028.
Translate
tpf70Author
Inspiring
Jan 19, 2009 9:49 PM UTC
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
Translate