Page 1 of 1

[no bug]setOverrideFont

Posted: Wed Jun 15, 2011 5:16 am
by Reiko
setOverrideFont doesn't seem to be working with the statictext part of a combobox.

Code: Select all

// Load some fonts
IGUIFont *font1 = guienv->getFont(L"font1.png");
IGUIFont *font2 = guienv->getFont(L"font2.png");

// Set default font to font1
guienv->getSkin()->setFont(font1);

// Make a static text, set override font to font2. This works.
guienv->addStaticText(L"Test", rect<s32>(20,20,120,40))->setOverrideFont(font2);

// Make a combo box
IGUIComboBox *combo = guienv->addComboBox(rect<s32>(20,60,120,80));
combo->addItem(L"item 1");
combo->addItem(L"item 2");
combo->addItem(L"item 3");

// Set override font on text part of combo box. Doesn't work, font used will be the skin's default (font1)
irr::core::list<IGUIElement *> kids = combo->getChildren();
for (irr::core::list<IGUIElement *>::Iterator i = kids.begin(); i != kids.end(); ++i)
{
	if (((stringc)(*i)->getTypeName()).equals_ignore_case("staticText") == 0)
	{
		static_cast<IGUIStaticText *>(*i)->setOverrideFont(font2);
	}
}
Should that be working or am I doing this wrong?

I haven't tried it with others though (eg. list box)

Posted: Thu Jun 16, 2011 10:01 pm
by CuteAlien
equals_ignore_case isn't like string compare returning 0 when equal, but it's a boolean - so you would check for true. But it's probably easier to check for getType() == EGUIET_STATIC_TEXT instead.

I haven't written a test now, but I think that should work then as there is nothing special done with fonts as far as I can see. If it still doesn't work just say it, then I take another look.

Posted: Fri Jun 17, 2011 9:13 am
by Reiko
Yup, it was my bad. It does work.

Thanks.