Page 1 of 1

How to scroll with StaticText from C++ side

Posted: Sun Oct 18, 2015 18:52
by jorisvial
Hi everyone,

I'm currently working on an in game chat. I use a GlossySerpentFHD/StaticText to display my messages (because I need text formatting)

To be abble to scroll the chat messages, I also set:

Code: Select all

 <Property name="VertScrollbar" value="true"/>

The only point remaining is about the auto scrolling. With the MultiLineEditBox a simple call is enought to scroll to the bottom:

Code: Select all

history->setCaretIndex(UINT_MAX)

Is there any way to get the same result with a StaticText ? I didn't find any solution on the forum/google, neither with the documentation.

Thank you a lot.
Best regards.

Re: How to scroll with StaticText from C++ side

Posted: Mon Oct 19, 2015 08:56
by YaronCT
jorisvial: if "r" is a pointer to your StaticText, you could do:

Code: Select all

r->getVertScrollbar()->setUnitIntervalScrollPosition(1.f);


The only problem is that "getVertScrollbar" is protected. I'll open a pull request to make it public. In the meantime u can either inherit StaticText or change in CEGUI code the access modifier of "getVertScrollbar" from "protected" to "public".

Re: How to scroll with StaticText from C++ side

Posted: Mon Oct 19, 2015 15:29
by jorisvial
I thought that CEGUI::StaticText doesn't exist as a CEGUI class. I guess I was wrong then. If it's the case I think it's way better to inherit from this class than modify the source code itself.

I will check that tonight and post how I did it.

Thanks a lot yaronct.

Re: How to scroll with StaticText from C++ side

Posted: Mon Oct 19, 2015 16:50
by jorisvial
Okay so first, CEGUI::StaticText class doesn't exist. However I found CEGUI::FalagardStaticText in "CEGUI\WindowRendererSets\Core\StaticText.h" but I can't get how to get the scrollbar from CEGUI::Window .

I found some interesting things. For now I'm trying to do like this :

Code: Select all

CEGUI::WindowRenderer* renderer = history->getWindowRenderer();
CEGUI::FalagardStaticText *staticText = static_cast<CEGUI::FalagardStaticText*>(renderer);
CEGUI::Scrollbar* scrollbar = staticText->getVertScrollbar();

The problem is that my program doesn't want to link :rofl:

Code: Select all

unresolved external symbol "__declspec(dllimport) public: class CEGUI::Scrollbar * __thiscall CEGUI::FalagardStaticText::getVertScrollbar(void)const " (__imp_?getVertScrollbar@FalagardStaticText@CEGUI@@QBEPAVScrollbar@2@XZ)

Any idea ? Am I totally wrong doing a game chat using static text ? Should I Implement my own scrolling system with a CEGUI::Scrollbar ? :D

Re: How to scroll with StaticText from C++ side

Posted: Mon Oct 19, 2015 17:42
by YaronCT
Your code seems fine. Make sure u link to "CEGUICoreWindowRendererSet" - that's where "FalagardStaticText" is defined.

Re: How to scroll with StaticText from C++ side

Posted: Mon Oct 19, 2015 18:05
by jorisvial
I've already trie to link with this library, it still doesn't work. Do I have the wrong libraries ?
Humph I will just add a scrollbar on top of my static text and implement myself scrolling since it's not hard at all.

But I'm still interested about the "real" solution.

Re: How to scroll with StaticText from C++ side

Posted: Mon Oct 19, 2015 18:09
by YaronCT
Did u manage to build and run the CEGUI sample framework?

Re: How to scroll with StaticText from C++ side

Posted: Mon Oct 19, 2015 18:40
by jorisvial
Well, I just switch on this project (that wasn't my part before). So I can't answer this. I think the guy before just found some precompiled .lib on the web ... :evil:

But anyway, I think it's better to implement my own scroll. This way I will be able easily apply filter.