Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
benb

updateSelection on Event.change of autoSize TLFTextField

Recommended Posts

I have a TLFTextField with autoSize set to TextFieldAutoSize.LEFT so when text is entered I need to have TransformManager update the selection rectangle and handles to the TLFTextField's new size. I tried adding an event listener to the TLFTextField for Event.CHANGE and then in the function calling updateSelection on the TransformManager. It seems to somewhat work in that the selection rectangle is sized for the TLFTextField's previous value. So for example, typing A, then B, then C, would cause the selection to be sized for "AB" instead of "ABC". So I'm guessing I need to adjust the order of when I call updateSelection to be later somehow, i.e. after the TLFTextField has resized itself (e.g. by perhaps listening for a different event). Has anyone figured out a solution for this? Thanks.

 

Ben

Link to comment
Share on other sites

To anyone else that runs into this, the workaround I've come to is to use an event listener for the text field's Event.CHANGE then in that handler add an event listener for Event.EXIT_FRAME. In the exit frame handler, the TransformManager selection controls can be updated (since by that time the text field has auto resized itself to its new text content). Although calling updateSelection on the TransformManager seems to work at first, when you click and drag a handle to resize the text field, the size jumps to a different size. So instead, I ask the TransformManager to deselect its selection and then re-select it. The Event.EXIT_FRAME handler then removes itself as a listener so that it is only called once. Not pretty, but it seems to work. Let me know if someone has a cleaner solution.

 

Ben

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×