Page 1 of 1

The colour about the selected brush image in ListboxTextItem

Posted: Wed May 18, 2011 07:10
by ogre2012
In the Sample_Demo7 project, there is some code as following:

Code: Select all

// Sample sub-class for ListboxTextItem that auto-sets the selection brush
// image.  This saves doing it manually every time in the code.
class MyListItem : public CEGUI::ListboxTextItem
{
public:
    MyListItem(const CEGUI::String& text) : ListboxTextItem(text)
    {
        setSelectionBrushImage("Stage", "roundBack");
    }
};

I set the selectionBrushImage successfully.But found that the colour is so blue.And my image is red.
How to keep the image’s colour?
Can you help me?
Thank you very much!!!!!

Re: The colour about the selected brush image in ListboxText

Posted: Wed May 18, 2011 07:28
by ogre2012
ogre2012 wrote:In the Sample_Demo7 project, there is some code as following:

Code: Select all

// Sample sub-class for ListboxTextItem that auto-sets the selection brush
// image.  This saves doing it manually every time in the code.
class MyListItem : public CEGUI::ListboxTextItem
{
public:
    MyListItem(const CEGUI::String& text) : ListboxTextItem(text)
    {
        setSelectionBrushImage("Stage", "roundBack");
    }
};

I set the selectionBrushImage successfully.But found that the colour is so blue.And my image is red.
How to keep the image’s colour?
Can you help me?
Thank you very much!!!!!


I have solved the problem.
--------------------------------------------------------------
setSelectionBrushImage("Stage", "roundBack");
CEGUI::colour c(1.0f, 1.0f, 1.0f, 1.0f);
setSelectionColours(c);
---------------------------------------------------------------------
But I met another problem.I need two images for the unselection items.Or set the two colours.
How to make it true?

Re: The colour about the selected brush image in ListboxText

Posted: Sun May 22, 2011 08:37
by CrazyEddie
When you need something more advanced than what is provided via the standard ListboxTextItem, the answer is to create a subclass - this enables you to use as many images and colours as you need :)

As an advanced example of such a subclass, there is a hack I made that allows you to use falagard xml skinning for your non-window based ListboxItems (with some limitations). This is described here: viewtopic.php?p=21975#p21975 but clearly you can do something simpler than this to achieve your goal :)

CE.