Hi all guys,
i am working with CEGUI::Scrollbar but i have a question:
can i set min and max value? default is 0.0 --> 1.0, can i modify it ...i don't find right "set" method...
EDIT: i read now document-size and page-size....but i need a range also negative...for example from -1.0 to 1.0, i need convert by hand???
thx a lot and sorry for "noob question"
Scrollbar, a lot of questions
Moderators: CEGUI MVP, CEGUI Team
Scrollbar, a lot of questions
Last edited by hurricane on Tue Dec 16, 2008 11:11, edited 1 time in total.
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Hi,
yes, you'll need to apply an appropriate offset in order to get negative values.
Since the scrollbar is meant to represent some position within some other entity (the document), in that context a negative position does not make sense. Obviously if you're using the scrollbar as an alternative to a slider, then the whole document/page/position abstraction does not really apply, so I know where you're coming from
CE.
yes, you'll need to apply an appropriate offset in order to get negative values.
Since the scrollbar is meant to represent some position within some other entity (the document), in that context a negative position does not make sense. Obviously if you're using the scrollbar as an alternative to a slider, then the whole document/page/position abstraction does not really apply, so I know where you're coming from
CE.
thx CE,
i have another question that i write here:
i need a particular behavior for my scrollbar. When the user press the scrollbar and move it (CEGUI::Scrollbar::EventScrollPositionChanged) i need that this event is fired while the mouse is not released (CEGUI::Scrollbar::EventMouseButtonUp).
i try do:
and the handler function:
but the applicition is blocked.. i think the System can't fire events...
any solution?
i have another question that i write here:
i need a particular behavior for my scrollbar. When the user press the scrollbar and move it (CEGUI::Scrollbar::EventScrollPositionChanged) i need that this event is fired while the mouse is not released (CEGUI::Scrollbar::EventMouseButtonUp).
i try do:
Code: Select all
wmgr.getWindow("Root/camera/position_x")->subscribeEvent(
CEGUI::Scrollbar::EventScrollPositionChanged,
Event::Subscriber(&gui::handleScrollbar,this));
and the handler function:
Code: Select all
bool gui::handleScrollbar(const CEGUI::EventArgs& args){
Window* window = static_cast<Window*>(static_cast<const WindowEventArgs&>(args).window);
while(!window->isEventPresent(CEGUI::Scrollbar::EventMouseButtonUp)){
// here my functions...
// here i need a CEGUI::System::doEvents(); ????
}
return true;
}
but the applicition is blocked.. i think the System can't fire events...
any solution?
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Hi,
isEventPresent does not do what you think it does
The easiest solution is to use the built-in auto-repeat features. On the scrollbar call:
or set the "MouseButtonDownAutoRepeat" property to "True". If you want all scrollbars to have this enabled, you can add a property initialiser to the scrollbar definition in the looknfeel file.
Note however, that depending on the looknfeel (basically proportional thumb, or not) and how you have the document size, page size, and such things set you can get into a "flicking" situation - where the thumb jumps past the point where mouse is held, then back again (because the mouse is now on the other side of the thumb, the next auto-repeat 'click' causes the thumb to jump back in the opposite direction, and so on).
CE.
isEventPresent does not do what you think it does
The easiest solution is to use the built-in auto-repeat features. On the scrollbar call:
Code: Select all
scrollbar->setMouseAutoRepeatEnabled( true );or set the "MouseButtonDownAutoRepeat" property to "True". If you want all scrollbars to have this enabled, you can add a property initialiser to the scrollbar definition in the looknfeel file.
Note however, that depending on the looknfeel (basically proportional thumb, or not) and how you have the document size, page size, and such things set you can get into a "flicking" situation - where the thumb jumps past the point where mouse is held, then back again (because the mouse is now on the other side of the thumb, the next auto-repeat 'click' causes the thumb to jump back in the opposite direction, and so on).
CE.
CrazyEddie wrote:Hi,
isEventPresent does not do what you think it does
The easiest solution is to use the built-in auto-repeat features. On the scrollbar call:Code: Select all
scrollbar->setMouseAutoRepeatEnabled( true );
or set the "MouseButtonDownAutoRepeat" property to "True". If you want all scrollbars to have this enabled, you can add a property initialiser to the scrollbar definition in the looknfeel file.
Note however, that depending on the looknfeel (basically proportional thumb, or not) and how you have the document size, page size, and such things set you can get into a "flicking" situation - where the thumb jumps past the point where mouse is held, then back again (because the mouse is now on the other side of the thumb, the next auto-repeat 'click' causes the thumb to jump back in the opposite direction, and so on).
CE.
CE, thanks for reply but i don't resolve my problem.
i added "setMouseAutoRepeatEnabled( true );" to my scrollbar but nothing changed...when i press mouse button on the "middle selector" of scrollbar and if i move it the event is fired but i want that this event is repeated while mouse isn't release...this not happens
also thanks, Martin
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Hmm, sorry. I got the wrong end of the stick
Scrap that then
Firstly, you can't ever sit in a loop within an event handler, especially not if you're waiting on some external event - all inputs are injected by you don't forget, so if you're sitting in a loop waiting for something to happen, you'll just hang.
I think basically what you need to do is:
Subscribe to Scrollbar::EventThumbTrackStarted and Scrollbar::EventThumbTrackEnded - these will inform you when the user 'grabs' and 'releases' the scrollbar thumb. Within the assigned handlers for these, you'll need to set and clear some state that will enable you to do something elsewhere depending upon whether the particular state is set.
Then either within your main loop, or perhaps in a Window::EventWindowUpdated handler, check the previously mentioned state and react according to whether the user current has the thumb 'grabbed'.
I think maybe that sounds vastly more complex than it really is:
Obviously that does not cater for >1 scrollbar, though that's easy to add yourself, I just wanted to show the basic concept (or at least one approach to it).
CE
Firstly, you can't ever sit in a loop within an event handler, especially not if you're waiting on some external event - all inputs are injected by you don't forget, so if you're sitting in a loop waiting for something to happen, you'll just hang.
I think basically what you need to do is:
Subscribe to Scrollbar::EventThumbTrackStarted and Scrollbar::EventThumbTrackEnded - these will inform you when the user 'grabs' and 'releases' the scrollbar thumb. Within the assigned handlers for these, you'll need to set and clear some state that will enable you to do something elsewhere depending upon whether the particular state is set.
Then either within your main loop, or perhaps in a Window::EventWindowUpdated handler, check the previously mentioned state and react according to whether the user current has the thumb 'grabbed'.
I think maybe that sounds vastly more complex than it really is:
Code: Select all
bool gui::thumbGrabbedHandler(const CEGUI::EventArgs& args)
{
mUserHasGrabbedThumb = true;
return true;
}
bool gui::thumbReleasedHandler(const CEGUI::EventArgs& args)
{
mUserHasGrabbedThumb = false;
return true;
}
bool gui::scrollbarUpdateHandler(const CEGUI::EventArgs& args)
{
if (mUserHasGrabbedThumb)
{
// TODO: Something useful!
}
return true;
}Obviously that does not cater for >1 scrollbar, though that's easy to add yourself, I just wanted to show the basic concept (or at least one approach to it).
CE
hi CE,
all now is more clear but how subscribe Window::EventWindowUpdated event?
with:
the event don't fire! must i fire it by hand in my main loop?
ps: the other two events work fine.
EDIT: i find the problem: i didn't inject time pulse. also thx Ce, i resolved!
all now is more clear but how subscribe Window::EventWindowUpdated event?
with:
Code: Select all
wmgr.getWindow("myScrollbar")->subscribeEvent(
CEGUI::Window::EventWindowUpdated,
Event::Subscriber(&gui::scrollbarUpdateHandler,this));
the event don't fire! must i fire it by hand in my main loop?
ps: the other two events work fine.
EDIT: i find the problem: i didn't inject time pulse. also thx Ce, i resolved!
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Who is online
Users browsing this forum: Baidu [Spider] and 23 guests
