How to scroll with StaticText from C++ side

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

jorisvial
Just popping in
Just popping in
Posts: 5
Joined: Sun Oct 18, 2015 18:42

How to scroll with StaticText from C++ side

Postby jorisvial » Sun Oct 18, 2015 18:52

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.

YaronCT
CEGUI Team
Posts: 448
Joined: Fri Jun 19, 2015 12:18
Location: Kiryat-Bialik, Israel

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

Postby YaronCT » Mon Oct 19, 2015 08:56

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".

jorisvial
Just popping in
Just popping in
Posts: 5
Joined: Sun Oct 18, 2015 18:42

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

Postby jorisvial » Mon Oct 19, 2015 15:29

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.

jorisvial
Just popping in
Just popping in
Posts: 5
Joined: Sun Oct 18, 2015 18:42

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

Postby jorisvial » Mon Oct 19, 2015 16:50

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

YaronCT
CEGUI Team
Posts: 448
Joined: Fri Jun 19, 2015 12:18
Location: Kiryat-Bialik, Israel

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

Postby YaronCT » Mon Oct 19, 2015 17:42

Your code seems fine. Make sure u link to "CEGUICoreWindowRendererSet" - that's where "FalagardStaticText" is defined.

jorisvial
Just popping in
Just popping in
Posts: 5
Joined: Sun Oct 18, 2015 18:42

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

Postby jorisvial » Mon Oct 19, 2015 18:05

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.

YaronCT
CEGUI Team
Posts: 448
Joined: Fri Jun 19, 2015 12:18
Location: Kiryat-Bialik, Israel

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

Postby YaronCT » Mon Oct 19, 2015 18:09

Did u manage to build and run the CEGUI sample framework?

jorisvial
Just popping in
Just popping in
Posts: 5
Joined: Sun Oct 18, 2015 18:42

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

Postby jorisvial » Mon Oct 19, 2015 18:40

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.


Return to “Help”

Who is online

Users browsing this forum: No registered users and 22 guests