Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
Is it possible to set the anchor point of a textfield? — Gideros Forum

Is it possible to set the anchor point of a textfield?

SPDAppsSPDApps Member
edited November 2012 in General questions
Im looking for a way to ser the anchor point or a textfield to the middle Is that possible?
Or Is it possible to have the text alignment from the center?

Comments

  • john26john26 Maintainer
    The anchor point for textfields is at the bottom left and cannot be changed. I use the following function to centre text
    function centreAt(sprite,x,y)
       local w=sprite:getWidth()
       local h=sprite:getHeight()
     
       sprite:setPosition(math.floor(x-w/2),math.floor(y+h/2))
    end
    Then call like this, for example,
    s=TextField.new(nil,"Hello, world")
    centreAt(s,100,100)
Sign In or Register to comment.