how obtein the position of the scroll in a scroll bar?

For help with anything that CEGUI doesn't offer straight out-of-the-box, e.g.:
- Implementation of new features, such as new Core classes, widgets, WindowRenderers, etc. ...
- Modification of any existing features for specific purposes
- Integration of CEGUI in new engines or frameworks and writing of new plugins (Renderer, Parser, ...) or modules

Moderators: CEGUI MVP, CEGUI Team

User avatar
pabloa
Not too shy to talk
Not too shy to talk
Posts: 37
Joined: Mon Oct 03, 2005 09:52

how obtein the position of the scroll in a scroll bar?

Postby pabloa » Mon Nov 21, 2005 09:42

Hi I would like see the new position of a scroll in a scroll bar? It started in the middle of the bar with

Code: Select all

sb->setScrollPosition(300.0f);

and I move it with the mouse, but It always get me the same position 300. I show it in s static text

Code: Select all

test->setText(CEGUI::PropertyHelper::floatToString(sb->getScrollPosition()));


Why this value didnt changed?

User avatar
martignasse
Just can't stay away
Just can't stay away
Posts: 227
Joined: Thu Apr 14, 2005 08:10
Location: Lyon, FRANCE

Re: how obtein the position of the scroll in a scroll bar?

Postby martignasse » Mon Nov 21, 2005 18:17

hi,

did you setup the document size and page size for you'r scrollbar ?

according to the API Reference doc, the formula used to provide you the scroll position surely use them.

hope it help.

User avatar
pabloa
Not too shy to talk
Not too shy to talk
Posts: 37
Joined: Mon Oct 03, 2005 09:52

Re: how obtein the position of the scroll in a scroll bar?

Postby pabloa » Tue Nov 22, 2005 09:49

yes I set up them, I used the formula to get the scroll position but didnt work

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

Re: how obtein the position of the scroll in a scroll bar?

Postby CrazyEddie » Tue Nov 22, 2005 12:38

The function works ok, since the itegrated scrollbars in list widgets and the demos all use this same function, and they work ;) So, something must be wrong in your app code.

Please post the code showing the creation and initialisation of the scrollbar.

User avatar
pabloa
Not too shy to talk
Not too shy to talk
Posts: 37
Joined: Mon Oct 03, 2005 09:52

Re: how obtein the position of the scroll in a scroll bar?

Postby pabloa » Tue Nov 22, 2005 14:09

here you are, I remove the ogre and newton code. I hope it was enought!

Code: Select all

 void createScene(void)
    {
      
        // setup GUI system
       mGUIRenderer = new CEGUI::OgreCEGUIRenderer(mWindow, Ogre::RENDER_QUEUE_OVERLAY, false, 3000);
              mGUISystem = new CEGUI::System(mGUIRenderer);
       CEGUI::Logger::getSingleton().setLoggingLevel(CEGUI::Informative);
 
       CEGUI::SchemeManager::getSingleton().loadScheme((CEGUI::utf8*)"TaharezLook.scheme");
       mGUISystem->setDefaultMouseCursor((CEGUI::utf8*)"TaharezLook", (CEGUI::utf8*)"MouseArrow");
       mGUISystem->setDefaultFont((CEGUI::utf8*)"Tahoma-12");
      mEditorGuiSheet= CEGUI::WindowManager::getSingleton().createWindow((CEGUI::utf8*)"DefaultWindow", (CEGUI::utf8*)"Sheet"); 
       mGUISystem->setGUISheet(mEditorGuiSheet);
  //End setup GUI system

      CEGUI::PushButton* quitButton = (CEGUI::PushButton*)CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/Button", (CEGUI::utf8*)"Quit");
      mEditorGuiSheet->addChildWindow(quitButton);
      quitButton->setPosition(CEGUI::Point(0.96f, 0.002f));
      quitButton->setSize(CEGUI::Size(0.04f, 0.04f));
      quitButton->setText("X");

      CEGUI::Scrollbar*  sb = (CEGUI::Scrollbar*)CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/HorizontalScrollbar", (CEGUI::utf8*)"Vert Scroll 1");
      mEditorGuiSheet->addChildWindow(sb);
       sb->setPosition(CEGUI::Point(0.30f, 0.98f));// posicion horizontal y posicion vertical
       sb->setMinimumSize(CEGUI::Size(0.01f, 0.01f));
       sb->setMaximumSize(CEGUI::Size(0.60f, 0.9f));
       sb->setSize(CEGUI::Size(0.8f, 0.015f)); //tamaño de largo y de ancho
       sb->setDocumentSize(360);
      
      sb->setPageSize(100);
       sb->setStepSize(1);
       sb->setAlwaysOnTop(true);
       sb->setScrollPosition(100.0f);


CEGUI::StaticText* test = (CEGUI::StaticText*)CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/Editbox", (CEGUI::utf8*)"test");
mEditorGuiSheet->addChildWindow(test);
test->setPosition(CEGUI::Point(0.1f, 0.1f));
test->setSize(CEGUI::Size(0.2f, 0.06f));
 test->setText(CEGUI::PropertyHelper::floatToString(sb->getScrollPosition()));*/

  //Ogre Elements

{HERE the rest of my program}


}
   


thank you!

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

Re: how obtein the position of the scroll in a scroll bar?

Postby CrazyEddie » Tue Nov 22, 2005 14:28

I think the problem is that you've not subscribed a handler to react when the scrollbar position changes; so the thing gets set once and that's it. You need some code to update the StaticText in response to changes in the scrollbar position.

As a test, I took your code, and added this handler function:

Code: Select all

bool myHandler(const CEGUI::EventArgs& e)
{
    CEGUI::Scrollbar*  sb = (CEGUI::Scrollbar*)CEGUI::WindowManager::getSingleton().getWindow((CEGUI::utf8*)"Vert Scroll 1");
    CEGUI::StaticText* test = (CEGUI::StaticText*)CEGUI::WindowManager::getSingleton().getWindow((CEGUI::utf8*)"test");
    test->setText(CEGUI::PropertyHelper::floatToString(sb->getScrollPosition()));

    return true;
}


And added this line after the rest of the init code in createScene:

Code: Select all

sb->subscribeEvent(CEGUI::Scrollbar::EventScrollPositionChanged, &myHandler);


HTH

CE.

User avatar
pabloa
Not too shy to talk
Not too shy to talk
Posts: 37
Joined: Mon Oct 03, 2005 09:52

Re: how obtein the position of the scroll in a scroll bar?

Postby pabloa » Wed Nov 23, 2005 10:13

Oh my god! now run :oops: I feel very silly :? Thanks


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 17 guests