ListBox with multi select

Post those lines of code you feel like sharing or find what you require for your project here; or simply use them as tutorials.
Post Reply
tom_gamer
Posts: 15
Joined: Sat Jun 01, 2013 8:51 am

ListBox with multi select

Post by tom_gamer »

Hi,

I had to write a little extension of the Listbox for my game. :wink:
With the code, you can make a ListBox do multiselect (select more than one item).
Image

This works only with mouse control (keyboard is not implemented for multiselect).

Here is the code based on irrlicht 1.8. Simply overwrite the existing files (in include dir and source/Irrlicht dir).

IGUIListBox.h
http://www.sourcepod.com/cbnzti23-18964

CGUIListBox.cpp
http://www.sourcepod.com/ysefyy43-18965

CGUIListBox.h
http://www.sourcepod.com/kyczac99-18966
Last edited by tom_gamer on Sun Jun 02, 2013 6:13 pm, edited 1 time in total.
SpaceCombat
http://sourceforge.net/projects/spacecombatgame
(OpenSource space combat simulation)
CuteAlien
Admin
Posts: 9643
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: ListBox with multi select

Post by CuteAlien »

You can use something like http://ideone.com/ for posting code. Sorry, but longer code-posts don't work in the forum (don't know why really, I wish it would work).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
chronologicaldot
Competition winner
Posts: 685
Joined: Mon Sep 10, 2012 8:51 am

Re: ListBox with multi select

Post by chronologicaldot »

Assuming it's clean of bugs, with your permission tom_gamer, we could put this in irrExt (our humble repositories). Someone (probably me) would have to double check for bugs and such.

Is there a specific reason why you named it IGUIListBox? I imagine you could have called it IGUIListBox2 and simply written an IGUIFactory implementation for it.
CuteAlien
Admin
Posts: 9643
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: ListBox with multi select

Post by CuteAlien »

Thanks for posting. I'll look at it if I ever try adding multiselect again (I already have 2 implementations, but both times didn't like 'em enough to add them to the engine itself).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
RdR
Competition winner
Posts: 273
Joined: Tue Mar 29, 2011 2:58 pm
Contact:

Re: ListBox with multi select

Post by RdR »

Looks good!
CuteAlien wrote:Thanks for posting. I'll look at it if I ever try adding multiselect again (I already have 2 implementations, but both times didn't like 'em enough to add them to the engine itself).
Created a patch for easier review:
http://pastebin.com/Pvz6Y2fj
CuteAlien
Admin
Posts: 9643
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: ListBox with multi select

Post by CuteAlien »

I see. Advantage that it doesn't change the interface much. Disadvantage would be that you always have to set all selected together instead of independent. I suppose setMultiSelect could be an internal protected member of the implementation class in this patch.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
tom_gamer
Posts: 15
Joined: Sat Jun 01, 2013 8:51 am

Re: ListBox with multi select

Post by tom_gamer »

chronologicaldot wrote:Assuming it's clean of bugs, with your permission tom_gamer, we could put this in irrExt (our humble repositories).
Permission given. (Keep in mind, that the code is mainly Irrlicht, that is licenced under zlib licence.)
chronologicaldot wrote:Is there a specific reason why you named it IGUIListBox?
I replaced the original files in my project. I'm using the guieditor often. So I don't had to re-compile it.
CuteAlien wrote:I already have 2 implementations, but both times didn't like 'em enough to add them to the engine itself
I would appreciate it if this functionality get's into the main Irrlicht stream. You may change the interface, of course... :wink:
SpaceCombat
http://sourceforge.net/projects/spacecombatgame
(OpenSource space combat simulation)
Post Reply