Hello,
I am doing time consuming rendering when the mouse moves a slider control (it updates the content of a panel).
In order to avoid latency due to too many motion events, I'd like to subsample them (i.e. discard some of them, but not just keep the mouse left up event).
Is there a way to do that or is it completely foolish?
Any idea?
Pascal
Subsampling an event queue
Re: Subsampling an event queue
Hi,
You could override wxApp::FilterEvent in your subclass, and do <whatever> to certain types of mouse events.
An example (looking a key events):
Regards,
David
You could override wxApp::FilterEvent in your subclass, and do <whatever> to certain types of mouse events.
An example (looking a key events):
Code: Select all
int MyApp::FilterEvent(wxEvent& event)
{
if (frame && event.GetEventType() == wxEVT_KEY_DOWN)
{ if (((wxKeyEvent&)event).GetKeyCode() == WXK_F1)
{ frame->OnHelpF1((wxKeyEvent&)event); return true; }
if (((wxKeyEvent&)event).GetKeyCode() == GetEscapeKeycode())
{ int flags = 0;
if (wxGetKeyState(WXK_CONTROL)) flags |= wxACCEL_CTRL; if (wxGetKeyState(WXK_ALT)) flags |= wxACCEL_ALT; if (wxGetKeyState(WXK_SHIFT)) flags |= wxACCEL_SHIFT;
if (flags == GetEscapeKeyFlags())
{ frame->DoOnProcessCancelled(); return -1; } // This time return -1 (== Skip()) as other things may use this keypress e.g. DnD
}
}
return -1;
}
David
Re: Subsampling an event queue
Hi David,
I think that's what I need. I should be able to do what I want with that. Many thanks for your help and your snippet.
Best regards,
Pascal
I think that's what I need. I should be able to do what I want with that. Many thanks for your help and your snippet.
Best regards,
Pascal