Jump to content
  • Advertisement
Sign in to follow this  
Decept

creating a custom listbox

This topic is 3543 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have made a fairly complex GUI system for my game engine and it works pretty good. But I'm having a problem with one control type, the listbox. I wanted the listbox to be very customizable, so what I did was to make it accept objects based on IListBoxItem. It has only two pure virtual functions, CreateControl() and Compare(). Compare() is for sorting items. In CreateControl() you create the item control you want and return a pointer to it. So if you wanted a listbox with buttons as items you would subclass IListBoxItem and in the CreateControl() you would create a button control and return it. This works fine, but I'm having problems selecting items. You see, I also want to be able to select and item. The idea is that if you click on the item area the item's background color will change. But if the item area is covered by a button the mouse-click would only go to the button object. I want the item to be selected even though you clicked on a child control inside it. I know it must be hard to help me with this as you have no idea how my GUI system works. But I'm really stuck here and would appreciate any ideas you might have. A mouse down message is sent to the topmost control under the cursor. The control receives the message inside its MessageHandler() and if it doesn't process the message it sends it to the GUI DefaultMessageHandler(). The GUI ystem is somewhat based on how Windows works. Any and all ideas will be much appreciated

Share this post


Link to post
Share on other sites
Advertisement
I had several complex ideas of how to solve this problem, but they never really worked. In the end I set textboxes to be "input transparent" as default. This way, if someone either clicks on an empty space inside an item or it's label (textbox), the listbox gets the input and selects the item. If one would create a checkbox inside an item, the checkbox would get the input and the item won't be selected.

This is still not a satisfying solution. I would like the item to be selected even if the checkbox is clicked. But this is better than nothing.

Share this post


Link to post
Share on other sites
Hello,

"A mouse down message is sent to the topmost control under the cursor. The control receives the message inside its MessageHandler() and if it doesn't process the message it sends it to the GUI DefaultMessageHandler()."

I think you should change this behaviour. If the control under the cursor isn't interested in a click message, it should either fall through the control behind it or be dispatched to another listener.

Hope this helps a bit.

Edit: And since you're planning to wrap different controls in a IListItem object, you should find a way to override the events they listen to.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!