Not every update, but the Window class (and therefore all widgets), have an auto-repeat function for the mouse buttons. This will not generate PushButton::EventClicked, but Window::MouseButtonDown messages, so you'll need to adjust where required.
To enable this you need to look at the function:
Window::setMouseAutoRepeatEnabled
For this to work, you also need to be correctly injecting time pulses each update via the function:
System::injectTimePulse
HTH
CE.
Subscriber problems
Moderators: CEGUI MVP, CEGUI Team
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Re: Subscriber problems
Useful Links: Forum Guidelines | Documentation | Tutorials | HOWTO | Videos | Donate to CEGUI | CEGUI Twitter
Re: Subscriber problems
That's great!
but what does the time injection do and why do I need it? Shouldn't it call the method every update?
but what does the time injection do and why do I need it? Shouldn't it call the method every update?
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Re: Subscriber problems
The time injection tells the system how long has passed since the last time injection - you need it because otherwise the functionality you wish to use will not work (nor will some other stuff, such as tool-tips).
If by every 'update' you mean every frame - if the event repeated every frame, then on some systems where you can get >1000 FPS, things would happen a bit too quickly This is why the injection system is used here, it allows the system to perform correct repeat-delat/repeat-rate timing.
If by every 'update' you mean every frame - if the event repeated every frame, then on some systems where you can get >1000 FPS, things would happen a bit too quickly This is why the injection system is used here, it allows the system to perform correct repeat-delat/repeat-rate timing.
Useful Links: Forum Guidelines | Documentation | Tutorials | HOWTO | Videos | Donate to CEGUI | CEGUI Twitter
Re: Subscriber problems
Well, the code I'm using doesn't really matter how fast it's updating, though the time injection might be helpful later on...
Though it doesn't seem to work properly...I don't think it is in fact getting called every update...Unless you have to have the time injection there for it to work.
Though it doesn't seem to work properly...I don't think it is in fact getting called every update...Unless you have to have the time injection there for it to work.
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Re: Subscriber problems
Yes, I already said this, but to reiterate...
You must inject the time pulses for the auto-repeat function to work.
You must inject the time pulses for the auto-repeat function to work.
Useful Links: Forum Guidelines | Documentation | Tutorials | HOWTO | Videos | Donate to CEGUI | CEGUI Twitter
Re: Subscriber problems
Well, i got that working no prob.
One thing missing now, I need a function to be called when I click one of the tab button. Is there a way to this from the tab control widget or do I have to get the window using the automatic name giving it to by cegui?
One thing missing now, I need a function to be called when I click one of the tab button. Is there a way to this from the tab control widget or do I have to get the window using the automatic name giving it to by cegui?
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Re: Subscriber problems
Well, there is:
TabControl::EventSelectionChanged
Which fires when the active tab is changed, which happens when somebody clicks the tab button.
If this is not acceptable, then you will have to obtain access to the button yourself; though as always, such low-level stuff must be classified as dangerous, and liable to break (though there are no plans in that area ).
TabControl::EventSelectionChanged
Which fires when the active tab is changed, which happens when somebody clicks the tab button.
If this is not acceptable, then you will have to obtain access to the button yourself; though as always, such low-level stuff must be classified as dangerous, and liable to break (though there are no plans in that area ).
Useful Links: Forum Guidelines | Documentation | Tutorials | HOWTO | Videos | Donate to CEGUI | CEGUI Twitter
Re: Subscriber problems
I'll see what I can do about that. I think EventSelectionChanged might help. I'll just need to devise a way to find out which child has been selected and that should be good.
Though in my opinion eddie, it would be nice to be able to put a normal button event on the tab buttons themselves without going through the low-level stuff. It can be as easy as just placing a common name to it instead of the automated code.
Just my thought cause some people would like that functionality. Heck, I could probbly do it myself if I have enough time to refine the code before my deadline
Though in my opinion eddie, it would be nice to be able to put a normal button event on the tab buttons themselves without going through the low-level stuff. It can be as easy as just placing a common name to it instead of the automated code.
Just my thought cause some people would like that functionality. Heck, I could probbly do it myself if I have enough time to refine the code before my deadline
Re: Subscriber problems
Well, I've been using the timeinjection extensively for testing. Right now I have this in my update function:
When the second are anything lower than that, it doesn't work.
I want it to be lower because the auto repeat for the mouse event gets fired around every half second, which isn't 0.01 second...
Is it possible to have it fired every frame update?
Code: Select all
CEGUI::System::getSingleton().injectTimePulse(0.01);
When the second are anything lower than that, it doesn't work.
I want it to be lower because the auto repeat for the mouse event gets fired around every half second, which isn't 0.01 second...
Is it possible to have it fired every frame update?
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Re: Subscriber problems
The value you pass in should not be constant - it's a measure of time between frames. It should work fine with lower values, initial testing for this was done on the Ogre driver running at 600 FPS, which would give an interval of around 0.00166f.
You set the delay and rate for the auto-repeat via the Window class API. (setAutoRepeatDelay & setAutoRepeatRate methods).
You set the delay and rate for the auto-repeat via the Window class API. (setAutoRepeatDelay & setAutoRepeatRate methods).
Useful Links: Forum Guidelines | Documentation | Tutorials | HOWTO | Videos | Donate to CEGUI | CEGUI Twitter
Re: Subscriber problems
CrazyEddie wrote:Ok. Consider the following code, which shows one general approach. There are some additional notes at the bottom of the post.Code: Select all
class myDemoClass_1
{
public:
// other methods
...
void assignHandlers();
//
// Handler methods
//
bool handleQuitButton(const CEGUI::EventArgs& args);
bool handleShowWindowButton(const CEGUI::EventArgs& args);
bool handleHideWindowButton(const CEGUI::EventArgs& args);
...
};
//
// code
//
void myDemoClass_1::assignHandlers()
{
using namespace CEGUI;
// get Window manager to save constantly getting singleton.
WindowManager& wmgr = WindowManager::getSingleton();
// find the quit button, and assign its handler
wmgr.getWindow("mySampleApp/QuitButton")->subscribeEvent(
PushButton::EventClicked,
Event::Subscriber(&myDemoClass_1::handleQuitButton, this));
// find the hide button, and assign its handler
wmgr.getWindow("mySampleApp/HideButton")->subscribeEvent(
PushButton::EventClicked,
Event::Subscriber(&myDemoClass_1::handleHideWindowButton, this));
// find the show button, and assign its handler
wmgr.getWindow("mySampleApp/ShowButton")->subscribeEvent(
PushButton::EventClicked,
Event::Subscriber(&myDemoClass_1::handleShowWindowButton, this));
}
bool myDemoClass_1::handleQuitButton(const CEGUI::EventArgs& args)
{
// this does not exist in this example, it's intended to
// represent a global object where we can signal the app
// to terminate.
myGlobalApp.signalQuit(true);
// signal that we handled the event, to prevent
// possible propogation of event to other windows.
return true;
}
bool myDemoClass_1::handleShowWindowButton(const CEGUI::EventArgs& args)
{
using namespace CEGUI;
WindowManager& wmgr = WindowManager::getSingleton();
// find the window to show/hide
wmgr.getWindow("mySampleApp/someWindow")->show();
// signal that we handled the event, to prevent
// possible propogation of event to other windows.
return true;
}
bool myDemoClass_1::handleHideWindowButton(const CEGUI::EventArgs& args)
{
using namespace CEGUI;
WindowManager& wmgr = WindowManager::getSingleton();
// find the window to show/hide
wmgr.getWindow("mySampleApp/someWindow")->hide();
// signal that we handled the event, to prevent
// possible propogation of event to other windows.
return true;
}
The key thing here, which some people initially miss, is the use of the 'this' pointer when creating the Event::Subscribers. Here we're passing 'this' because this is an instance of the object containing the handler functions. If your handler functions were in some other class, say 'myHandlersClass', then instead of passing 'this' you would need to pass a pointer to an instance of the 'myHandlersClass'. If you are subscribing free functions, or static member functions you do not need this object pointer at all, and can just pass a pointer to the function.
this is what i did:
Code: Select all
theMainFrame->subscribeEvent(FrameWindow::EventCloseClicked, &allOver);
bool allOver(e) is a subscribing free function.
and i got access violation.
Return to “Modifications / Integrations / Customisations”
Who is online
Users browsing this forum: No registered users and 7 guests