Hello
I have run across something that I am sure is rather easy, but for some reason I just can't wrap my head around it... hence it enters the beginners help section
Now a normal guienv->addListBox() listbox has a scrollbar... how do I access it? If I made my own gui element with a scrollbar I wouldn't have this problem... but atm we are talking about a normal Listbox
I am sure it is registered as a child of some form to the listbox, hence I should be able to get it with a listbox->getChildren... right?
Now that baby returns a core::list... now how the heck do I sort out the scrollbar from that list
I would like to assign the scrollbar to a IGUIScrollBar*
this does not only apply to the listbox+scrollbar... i mean it a bit more generally as well
thanks in advance
Listbox / scrollbar problem
I dunno why you would want a handle to the scrollbar of the combobox element. Normally you would expect the combobox to manage its own internal controls and you would leave it alone.
If you really need to get the scrollbar, you would iterate through the list of controls looking for one that returns EGUIET_SCROLL_BAR when you call getType(). You _may_ need to recursively iterate through the list because there is no guarantee that the scrollbar is a child of the combobox. It could very well be a child of a child of the combobox.
Travis
If you really need to get the scrollbar, you would iterate through the list of controls looking for one that returns EGUIET_SCROLL_BAR when you call getType(). You _may_ need to recursively iterate through the list because there is no guarantee that the scrollbar is a child of the combobox. It could very well be a child of a child of the combobox.
Travis
thanks for the feedback but I am still running into some difficulties
now, as far as I can tell, the core::list does not seem to use / have an [] operator... some part of me is asking how that is possible, but after going through the class and reading the debug log I have to say that it seems possible.
which brings me my next little problem, how do I iterate through it?
the iterator class inside the list has struck my mind... but I can once again ( after much trail and error ) not get it functioning
the reason why I want access to the scrollbar in the first place is mainly that the listbox always shows the top of the listbox. the first added items. I need it to show the last added item , the bottom.
thanks again
now, as far as I can tell, the core::list does not seem to use / have an [] operator... some part of me is asking how that is possible, but after going through the class and reading the debug log I have to say that it seems possible.
which brings me my next little problem, how do I iterate through it?
the iterator class inside the list has struck my mind... but I can once again ( after much trail and error ) not get it functioning
the reason why I want access to the scrollbar in the first place is mainly that the listbox always shows the top of the listbox. the first added items. I need it to show the last added item , the bottom.
thanks again
Yes, lists do not have operator[]. You have to use the iterator interfaces provided...
Unfortunately, I don't think this will help to solve your problem.
Travis
Code: Select all
core::list<gui::IGUIElement*>& m = box->getChildren();
// put some values into m
core::list<gui::IGUIElement*>::Iterator head = m.begin();
core::list<gui::IGUIElement*>::Iterator tail = m.end();
// iterators act much like a pointer, so you access the data that it refers to by using the dereferencing operator-> or operator*
for (/**/; head != tail; ++head)
{
gui::IGUIElement* element = *head;
if (element->getType() == EGUIET_SCROLLBAR)
{
gui::IGUIScrollBar* sb = (gui:IGUIScrollBar*)element;
// screw with the scrollbar
}
}
Travis