Hi,
I had to write a little extension of the Listbox for my game.
With the code, you can make a ListBox do multiselect (select more than one item).
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
ListBox with multi select
ListBox with multi select
Last edited by tom_gamer on Sun Jun 02, 2013 6:13 pm, edited 1 time in total.
Re: ListBox with multi select
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
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
-
- Competition winner
- Posts: 688
- Joined: Mon Sep 10, 2012 8:51 am
Re: ListBox with multi select
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.
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.
Re: ListBox with multi select
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
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: ListBox with multi select
Looks good!
http://pastebin.com/Pvz6Y2fj
Created a patch for easier review: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).
http://pastebin.com/Pvz6Y2fj
Re: ListBox with multi select
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
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: ListBox with multi select
Permission given. (Keep in mind, that the code is mainly Irrlicht, that is licenced under zlib licence.)chronologicaldot wrote:Assuming it's clean of bugs, with your permission tom_gamer, we could put this in irrExt (our humble repositories).
I replaced the original files in my project. I'm using the guieditor often. So I don't had to re-compile it.chronologicaldot wrote:Is there a specific reason why you named it IGUIListBox?
I would appreciate it if this functionality get's into the main Irrlicht stream. You may change the interface, of course...CuteAlien wrote:I already have 2 implementations, but both times didn't like 'em enough to add them to the engine itself