2020-03-04 02:17 AM
I want to use container as Drawable*, so I can use methods like moveTo() etc. to move the container around.
I have my container in View, which is selectorboxContainer, which inherits from selectorboxContainerBase, which inherits from touchgfx::Container, which inheirts from Drawable.
I can get Drawable* to this object using this method:
Drawable* selectorbox = getFirstChild();
But I cannot do it like this:
Drawable* selectorbox = (Drawable*) selectorBox1;
I get error:
error: invalid cast from type 'selectorboxContainer' to type 'touchgfx::Drawable*'
Why getFirstChild() can cast my container to Drawable*, but I cannot do it by casting?
I don't want to use getFirstChild(), because it blindly picks Drawable based on order, instead of the drawable name. If someone reorders drawables, it will break the application.
Solved! Go to Solution.
2020-03-04 11:20 AM
Hi,
this should work:
Drawable* selectorbox = (Drawable*)&selectorBox1;
but there is no need for a cast, you can move the container directly (as you mentioned, the custom container is derived from Drawable)
selectorBox1.moveTo(20,20);
Best regards,
Peter
2020-03-04 11:20 AM
Hi,
this should work:
Drawable* selectorbox = (Drawable*)&selectorBox1;
but there is no need for a cast, you can move the container directly (as you mentioned, the custom container is derived from Drawable)
selectorBox1.moveTo(20,20);
Best regards,
Peter