How to change Width of a native.newTextBox on button click?

Hey all, I posted this in the general section, but it seems like it belongs here:

I’ve created a native.newTextBox with a width of 800px.  I want to be able to dynamically move and change the width of this textbox to 400px when I click a button and then change it back to 800px when I click it again.  The problem is that the textbox keeps shrinking every time a click the button and never reverts back to the 800px.

 

My code for the button to control the textbox is as follows:

 

if ( “ended” == event.phase ) then

  if ButtonName == “Tab1” then

     print( “Button was pressed and released” )

     if (textBox.x>100) then

         transition.to( textBox, { x=50, width=860, time=200 } )

     else

         transition.to( textBox, { x=400, width=500, time=200 } )

     end

  end

end

 

How do I change the width of this native.newTextBox on fly?

 

Thanks!

At this point, I don’t even need to transition it. I just need to change the x position (easy) and the width of the textbox on the fly… Help!

Hi @zolnier,

I don’t think it’s possible to change the size post-creation, but you could remove the current box, replace it with a larger one, and populate its text content with the text from the box that was removed.

Take care,

Brent

Yeah, Brent - that’s what I was thinking I would have to do, too.  Thanks!

At this point, I don’t even need to transition it. I just need to change the x position (easy) and the width of the textbox on the fly… Help!

Hi @zolnier,

I don’t think it’s possible to change the size post-creation, but you could remove the current box, replace it with a larger one, and populate its text content with the text from the box that was removed.

Take care,

Brent

Yeah, Brent - that’s what I was thinking I would have to do, too.  Thanks!