ItemListbox double click

Forum for general chit-chat or off-topic discussion.

Moderators: CEGUI MVP, CEGUI Team

dewyatt
Not too shy to talk
Not too shy to talk
Posts: 28
Joined: Sat Jun 14, 2008 21:26

ItemListbox double click

Postby dewyatt » Mon Sep 01, 2008 14:44

I would like to respond to double click events in an ItemListbox.
Does such an event exist?

Also, how would I allow editing in an ItemListbox?
I don't think this is directly supported, but how would I add it?

Jamarr
CEGUI MVP
CEGUI MVP
Posts: 812
Joined: Tue Jun 03, 2008 23:59
Location: USA

Postby Jamarr » Tue Sep 02, 2008 18:41

Regarding events, you can answer these questions yourself by reading through the tutorials/API. But here you go anyway:

Code: Select all

_pListbox->subscribeEvent(CEGUI::ItemListbox::EventMouseDoubleClick, CEGUI::Event::Subscriber(&WinMain::OnMouseDoubleClick, this));


Regarding activly editing listbox items, you can derive the solution from this wiki page: http://www.cegui.org.uk/wiki/index.php/Create_a_CheckListboxItem

I was going to implement this same functionality previously, so I can post some example code for you. In the end I decided to take a different route, so you may need to delve a bit deeper yourself:

Based on WindowsLook.looknfeel:

Code: Select all

<!--
***************************************************
   WindowsLook/EditListboxItem
***************************************************
-->   
<WidgetLook name="WindowsLook/EditListboxItem">
   <PropertyDefinition name="TextColour" initialValue="FF000000" redrawOnWrite="true" />
   <PropertyDefinition name="SelectedTextColour" initialValue="FFFFFFFF" redrawOnWrite="true" />
   <PropertyDefinition name="SelectionBrush" initialValue="set:WindowsLook image:Background" redrawOnWrite="true" />
   <PropertyDefinition name="SelectionColour" initialValue="FF3030FF" redrawOnWrite="true" />
   <Property name="Selectable" value="True" />
   <NamedArea name="ContentSize">
      <Area>
         <Dim type="LeftEdge" >
            <AbsoluteDim value="0" />
         </Dim>
         <Dim type="TopEdge" >
            <AbsoluteDim value="0" />
         </Dim>
         <Dim type="Width" >
            <FontDim type="HorzExtent" />
         </Dim>
         <Dim type="Height" >
            <FontDim type="LineSpacing" padding="10" />
         </Dim>
      </Area>
   </NamedArea>
   <Child type ="WindowsLook/Editbox" nameSuffix="__auto__editbox">
      <Area>
         <Dim type="LeftEdge">
            <UnifiedDim scale="0" type="LeftEdge" />
         </Dim>
         <Dim type="TopEdge">
            <UnifiedDim scale="0" type="TopEdge" />
         </Dim>
         <Dim type="Width">
            <UnifiedDim scale="1" type="Width" />
         </Dim>
         <Dim type="Height">
            <UnifiedDim scale="1" type="Height"/>
         </Dim>
      </Area>
   </Child>
   <ImagerySection name="label">
      <TextComponent>
         <Area>
            <Dim type="TopEdge">
               <AbsoluteDim value="0" />
            </Dim>
            <Dim type="LeftEdge">
               <AbsoluteDim value="3" />
            </Dim>
            <Dim type="RightEdge">
               <UnifiedDim scale="1" offset="-3" type="RightEdge" />
            </Dim>
            <Dim type="BottomEdge">
               <UnifiedDim scale="1" type="BottomEdge" />
            </Dim>
         </Area>
      </TextComponent>
   </ImagerySection>
   <ImagerySection name="selection">
      <ImageryComponent>
         <Area>
            <Dim type="TopEdge">
               <AbsoluteDim value="0" />
            </Dim>
            <Dim type="LeftEdge">
               <AbsoluteDim value="0" />
            </Dim>
            <Dim type="RightEdge">
               <UnifiedDim scale="1" type="RightEdge" />
            </Dim>
            <Dim type="BottomEdge">
               <UnifiedDim scale="1" type="BottomEdge" />
            </Dim>
         </Area>
         <ImageProperty name="SelectionBrush" />
         <ColourProperty name="SelectionColour" />
         <VertFormat type="Stretched" />
         <HorzFormat type="Stretched" />
      </ImageryComponent>
   </ImagerySection>
   <StateImagery name="Enabled">
      <Layer>
         <Section section="label">
            <ColourProperty name="TextColour" />
         </Section>
      </Layer>
   </StateImagery>
   <StateImagery name="Disabled">
      <Layer>
         <Section section="label">
            <ColourProperty name="TextColour" />
         </Section>
      </Layer>
   </StateImagery>
   <StateImagery name="SelectedEnabled">
      <Layer>
         <Section section="selection" />
         <Section section="label">
            <ColourProperty name="SelectedTextColour" />
         </Section>
      </Layer>
   </StateImagery>
   <StateImagery name="SelectedDisabled">
      <Layer>
         <Section section="selection" />
         <Section section="label">
            <ColourProperty name="SelectedTextColour" />
         </Section>
      </Layer>
   </StateImagery>
</WidgetLook>

dewyatt
Not too shy to talk
Not too shy to talk
Posts: 28
Joined: Sat Jun 14, 2008 21:26

Postby dewyatt » Wed Sep 03, 2008 09:11

Thanks.
I've read through the documentation and tutorials.
ItemListbox has a longer hierarchy than most and the documentation won't show the full hierarchy on its class page.
So I somehow didn't realize it did, ultimately, derive from Window (should have known but I guess I wasn't thinking).

Thanks a lot for the looknfeel, that should be helpful.


Return to “Offtopic Discussion”

Who is online

Users browsing this forum: No registered users and 7 guests