Skip to main content
tantra35
Participant
December 24, 2014
Question

TextField 2 pixel offset

  • December 24, 2014
  • 1 reply
  • 289 views

Hello

I try to get Textfiled coords, with follow code(in coordinate system of textField itself)

textField.getBounds(textField)

and I found, that we get 2 pixel offset in target coordinate system

"bounds": {
      "topLeft": {
        "y": -2
        "x": -2,
       "length": 2.8284271247461903       },       "right": 127.44999999999999,       "bottomRight": {         "y": 36.1,         "x": 127.44999999999999,         "length": 132.4640045446309       }, 

As you can see x=-2, y=-2, but i expect that x will be 0, and y will be 0.

In other case we get much bigger offset on x axis:

"bounds": {
      "topLeft": {
        "y": -2, 
        "x": 31.65, 
        "length": 31.71312819637949       },       "right": 195.65,       "bottomRight": {         "y": 49,         "x": 195.65,         "length": 201.69264364373828       },

}

Anybody can explain this behavior of TextField

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
December 24, 2014

that's probably dependent on the font used and its ascenders/descenders.

tantra35
tantra35Author
Participant
December 25, 2014

Sorry but i misundestend what is font ascender/descender?