autoscroll and no horiz scrollbar for Listbox

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

User avatar
rogerdv
Quite a regular
Quite a regular
Posts: 62
Joined: Thu Mar 31, 2005 23:21
Contact:

autoscroll and no horiz scrollbar for Listbox

Postby rogerdv » Mon Nov 12, 2007 17:25

I need to remove the horizontal scroll for a listbox, and scroll the text whenever I add a new text line. How can I do this?

Pompei2
Home away from home
Home away from home
Posts: 489
Joined: Tue May 23, 2006 16:31

Postby Pompei2 » Tue Nov 13, 2007 00:13

Is this for a chat ?

Code: Select all

    try {
        LB->addItem(this);

        // Care to not overfill the listbox.
        while(LB->getItemCount() > D_MAX_CHAT_ENTRIES) {
            LB->removeItem(LB->getListboxItemFromIndex(0));
        }

        LB->ensureItemIsVisible(this);
    } catch(CEGUI::Exception & e) {
        FTS18N("CEGUI", FTS_ERROR, e.getMessage().c_str());
    }


This is a code snippet from my chat handling listbox. It does add a new item to the listbox (the new item being "this"), scroll the listbox down so the new item can be seen (ensureItemIsVisible) and also cares to not over-fill the listbox, else CEGUI gets very slow !! 100 is a good value for D_MAX_CHAT_ENTRIES.


In the default TaharezLook listbox, there seems to be no way to suppress the horizontal scrollbar, you will need to create your own look'n'feel file for the listbox. It's not too hard ;)

User avatar
rogerdv
Quite a regular
Quite a regular
Posts: 62
Joined: Thu Mar 31, 2005 23:21
Contact:

Postby rogerdv » Thu Nov 15, 2007 19:53

No, it is an RPG. I need a continuous flow of ingame messages on that listbox, and the only solution I see to avoid scrolling horizontally is to expand the width.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Fri Nov 16, 2007 09:53

The 'right' way that you should be able to get it to work is by writing a customised item for the list box that has a fixed width (and that wraps the content as needed), this would ensure that there is never any need to scroll horizontally.

The 'hacky' way is to pre-process the item lines to be added, splitting them into multiple items (lines) before adding them.


Return to “Help”

Who is online

Users browsing this forum: No registered users and 22 guests