0 votes

when i create a control (c++)
then some of the properties are ignored.

in my case its a texture button, and set_scale():

            TextureButton* tbut1 = memnew(TextureButton()); 

            // also sets size to size of texture (1024x1024 in my case) 
            // ignoring STRETCH_SCALE

            // not needed, since sizeof texture much bigger (in this example)
            //tbut1->set_custom_minimum_size(Size2(20, 20)); 

            //for some reason texButton completely ignores size, 
            //even with STRETCH_SCALE
            tbut1->set_size(Size2(20, 20)); 
            tbut1->update(); //ignored since (pending_update = true;)
            tbut1->set_scale(Vector2(0.02, 0.02)); // it is ignored...
            tbut1->update(); //ignored since (pending_update = true;)

tbut1->set_scale(Vector2(0.02, 0.02)); is ignored at "creation time"

but when i call it (for test purpose) in the onClicked Handler, its gets scaled.
maybe has something todo with the (pending_update = true;)

what am i missing?

EDIT: changed header description to a better meaning

in Engine by (63 points)
edited by

I think you should create instance by TextureButton* tbut1 = memnew(TextureButton);
not TextureButton* tbut1 = memnew(TextureButton());

ofc thats true, tnx for hint :)

1 Answer

0 votes
Best answer

ok got it:

    tbut1->set_custom_minimum_size(Size2(20, 20));
    //tbut1->set_size(Size2(20, 20)); // not needed since min size is 20/20

maybe one should consider changing the property expand to allow/enable_stretching,
although its a bit confusing for this use case.

i think the different behavior (when one change properties anywhere else then directly after create)
may be a effect that the size is determined when the control gets drawn, so there is diffrent behaviour of a control once its drawn.

by (63 points)
edited by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.