Languages

Menu
Sites
Language
Getting Text Width in EDC

I want to slide text in my application, for that I need to know the width of the text I am setting, So that I can have uniform, text sliding speed for long and short text .

I tried using the Script

script{
    public myX, myY, myW, myH;

    public slide_to_end_anim(val, Float:pos) {
      set_tween_state(PART:"elm.text", pos, "end", 0.0, "begin", 0.0);
   }
 
    public GetTextExtent() {

       new Float:time;
      get_geometry(PART:"elm.text", myX, myY, myW, myH);

      time = SPEED/myW;

      anim(time, "my_anim", 1);
    }  
 }

but get_geometry() is giving the width of the text container and not of the text.

Please guide, is there any Embryo API, or any other way, I can get the text width.

Thanks in advance.

 

View Selected Answer

Responses

2 Replies
Mark as answer
Jeongsu Kim

add another invisible part to get text size like below (fill other attributes you need)

part {
    name: "elm.text.size_calculator";
    visible: 0;
    ...
    description {
        text {
            min: 1 1;
            text_source: "elm.text";
        }
    }
}

this part is resized by it's text size.

Veenu Pandey

Thank a lot.
It solved my problem.