and i want to create the scroll bar to point at the end of the chat box and stay at the current point if the scroll bar are moved to the other position
(i'm using list box as a chat box)
the scroll bar then will be locked again once the user drag it to the end
the problem is i dont know how to get the maximum number of the scroll bar position
i'm using these code to get the maximum number of the scrollbar position and compare it with current position (if not same then the bar is moved to another place):
Code: Select all
bar->getDocumentSize() - bar->getPageSize()
below is the snippet of the code
Code: Select all
bool handle_GameRoomChat(const CEGUI::EventArgs& args){
using namespace CEGUI;
// initialize window manager
WindowManager *wmgr = WindowManager::getSingletonPtr();
//initialize chat window
Listbox* chatLog = static_cast<Listbox*> (wmgr->getWindow((utf8*)"GameRoom/ChatLog"));
Window *chat = wmgr->getWindow((utf8*)"GameRoom/ChatInput");
ListboxTextItem* chatItem;
if(!chat->getText().empty()){
bool notMove = true;
Scrollbar *bar = chatLog->getVertScrollbar();
if(bar->getScrollPosition() < (bar->getDocumentSize() - bar->getPageSize()))
notMove = false;
chatItem = new ListboxTextItem(chat->getText());
chatLog->addItem(chatItem);
if(notMove)
bar->setScrollPosition(bar->getDocumentSize() - bar->getPageSize());
}
chat->setText("");
return true;
}
is not really crucial in the system but i think it is kinda annoying while you scroll up want to read the chat history and suddenly someone chat with you and scroll you down
any help is appreciated
thank you