Trying to programmatically create ImageButton
Posted: Sat Jan 02, 2016 20:00
As the topic states I'm trying to programmatically create a TaharezLook/ImageButton, for a build menu. So far I've had an easier time creating a normal TaharezLook/Button and using text markup to insert an image, while the ImageButton doesn't show up at all. I have tried a lot of things but right now I'm at a loss as to where to look for info or what to try next.
The code as it stands, first for creating the ImageButton, then the normal Button:
The resulting window:
http://i.imgur.com/OkpxUTH.png
The button you see in the window is the second Button, the one using text markup. The first button doesn't show up at all.
Any ideas or advice?
The code as it stands, first for creating the ImageButton, then the normal Button:
Code: Select all
CEGUI::FrameWindow* ArenaLayer::createBuildMenu() {
CEGUI::WindowManager& winMgr = CEGUI::WindowManager::getSingleton();
CEGUI::FrameWindow* window = dynamic_cast<CEGUI::FrameWindow*>(winMgr.createWindow("TaharezLook/FrameWindow", "buildMenu"));
{
CEGUI::PushButton* button = dynamic_cast<CEGUI::PushButton*>(winMgr.createWindow("TaharezLook/ImageButton", "button"));
//button->setProperty("NormalImage", "set:TaharezLook image:CheckboxNormal");
//button->setProperty("NormalImage", "TaharezLook/CheckboxNormal");
button->setProperty("Position", "{{0,0},{0,0}}");
button->setProperty("Size", "{{0,64},{0,20}}");
button->setProperty("NormalImage", "TaharezLook/CheckboxNormal");
button->setProperty("HoverImage", "TaharezLook/CheckboxNormal");
button->setProperty("PushedImage", "TaharezLook/CheckboxNormal");
button->setProperty("DisabledImage", "TaharezLook/CheckboxNormal");
window->addChild(button);
//CEGUI::System::getSingletonPtr()->getDefaultGUIContext().getRootWindow()->addChild(button);
}
{
CEGUI::PushButton* button = dynamic_cast<CEGUI::PushButton*>(winMgr.createWindow("TaharezLook/Button", "button2"));
button->setText(std::string{ "X[colour='88888888']X[colour='ffffffff']X[image-size='w:32 h:32'][image='" } + TextureController::Instance.getCEGUIImageName(TileType::DEER) + std::string{ "']" });
window->addChild(button);
}
VLOG(2) << "Created buildMenu";
return window;
}
The resulting window:
http://i.imgur.com/OkpxUTH.png
The button you see in the window is the second Button, the one using text markup. The first button doesn't show up at all.
Any ideas or advice?