Page 1 of 1

Making a list box selectable [Solved]

Posted: Sat Mar 25, 2006 21:24
by Scorch
I am using 0.4.1 CEGUI, and the CEGUI layout editor.
I have a page with 2 list box's on them. I can add to my list boxes text and it apears just fine.
Problem is I want to make the list box items selectable, right now you click on them and nothing happens. They should highlight or somthing right?

Do i have to register for handlers and somehow highlight them myself?

Here is my layout file:


Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<GUILayout>
<Window Type="DefaultWindow" Name="Lobby_Root" >
<Property Name="UnifiedAreaRect" Value="{{0.000000,0.000000},{0.000000,0.000000},{1.000000,0.000000},{1.000000,0.000000}}" />
<Property Name="UnifiedMaxSize" Value="{{1.000000,0.000000},{1.000000,0.000000}}" />
<Window Type="TaharezLook/FrameWindow" Name="Lobby_LobbyWindow" >
<Property Name="CaptionColour" Value="00FFFFFF" />
<Property Name="EWSizingCursorImage" Value="set:TaharezLook image:MouseEsWeCursor" />
<Property Name="Font" Value="Tahoma-12" />
<Property Name="MouseCursorImage" Value="set:TaharezLook image:MouseTarget" />
<Property Name="NESWSizingCursorImage" Value="set:TaharezLook image:MouseNeSwCursor" />
<Property Name="NSSizingCursorImage" Value="set:TaharezLook image:MouseNoSoCursor" />
<Property Name="NWSESizingCursorImage" Value="set:TaharezLook image:MouseNwSeCursor" />
<Property Name="TitlebarEnabled" Value="True" />
<Property Name="TitlebarFont" Value="Tahoma-12" />
<Property Name="UnifiedAreaRect" Value="{{0.012500,0.000000},{0.022917,0.000000},{0.985937,0.000000},{0.987500,0.000000}}" />
<Property Name="UnifiedMaxSize" Value="{{1.000000,0.000000},{1.000000,0.000000}}" />
<Window Type="TaharezLook/Listbox" Name="AvailableServers" >
<Property Name="Font" Value="Tahoma-12" />
<Property Name="MouseCursorImage" Value="set:TaharezLook image:MouseArrow" />
<Property Name="MultiSelect" Value="True" />
<Property Name="Sort" Value="True" />
<Property Name="UnifiedAreaRect" Value="{{0.039968,0.000000},{0.092656,0.000000},{0.720145,0.000000},{0.848056,0.000000}}" />
<Property Name="UnifiedMaxSize" Value="{{1.000000,0.000000},{1.000000,0.000000}}" />
</Window>
<Window Type="TaharezLook/Button" Name="Lobby_Cancel" >
<Property Name="Font" Value="Tahoma-12" />
<Property Name="MouseCursorImage" Value="set:TaharezLook image:MouseArrow" />
<Property Name="Text" Value="Cancel" />
<Property Name="UnifiedAreaRect" Value="{{0.807384,0.000000},{0.889850,0.000000},{0.959470,0.000000},{0.958424,0.000000}}" />
<Property Name="UnifiedMaxSize" Value="{{1.000000,0.000000},{1.000000,0.000000}}" />
</Window>
<Window Type="TaharezLook/Button" Name="Lobby_OK" >
<Property Name="Font" Value="Tahoma-12" />
<Property Name="MouseCursorImage" Value="set:TaharezLook image:MouseArrow" />
<Property Name="Text" Value="OK" />
<Property Name="UnifiedAreaRect" Value="{{0.628090,0.000000},{0.888337,0.000000},{0.778572,0.000000},{0.963391,0.000000}}" />
<Property Name="UnifiedMaxSize" Value="{{1.000000,0.000000},{1.000000,0.000000}}" />
</Window>
<Window Type="TaharezLook/Listbox" Name="Lobby_ServerStatistics" >
<Property Name="Font" Value="Tahoma-12" />
<Property Name="MouseCursorImage" Value="set:TaharezLook image:MouseTarget" />
<Property Name="UnifiedAreaRect" Value="{{0.752167,0.000000},{0.094168,0.000000},{0.970064,0.000000},{0.843089,0.000000}}" />
<Property Name="UnifiedMaxSize" Value="{{1.000000,0.000000},{1.000000,0.000000}}" />
</Window>
</Window>
</Window>
</GUILayout>


I tried turning on MultiSelect to see if that did anything, but nothing so far.

Any idea's?

Posted: Sun Mar 26, 2006 18:19
by lindquist
You need to set the selection colour and the selection brush image for each item.

[edit]This can only be done from code as you cannot define the list items from XML[/edit]

Posted: Sun Mar 26, 2006 20:52
by Scorch
Ok, I believe you. But I can't find the code that does this.

I looked though the CEGUIListbox.h and CEGUIWindow.h and I cant find any set, select, or color that suggests it will do as you suggest.

I also did a couple find in files of the whole CEGUI directory, and the only thing I can find is text lines in one of the demo xmls.

i'm going to do some more wiki searchs and look through the demo code, but if you can point me in the right direction that would be great.

Posted: Sun Mar 26, 2006 21:11
by Scorch
Found it!
found a wiki page:
http://www.cegui.org.uk/wiki/index.php/FAQ

And I am now able to highlight selected items!

Thanks!

Wasn't obvious to me because I didn't realize I could set the selection color individualy for each item. But I can see where that would be usefull.

I am suprised there isn't a default color section for the listbox available in XML. But thats ok now that I got it working.

Posted: Mon Aug 21, 2006 20:44
by arkos
I just wanted to add something.

If you are using WindowsLook, you need to make sure that the ListboxSelectionBrush exists in the imageset file. Then you need to make sure that the square it corresponds to in the targa file has a white alpha. The actual color channel can just be left blank because you are giving it a color when you setSelectionColours().

I was beating my head on a table for hours trying to figure why the selection wouldn't show up!