How to unresister Click and Drag Event manually
Hi,
I'm trying to change screen with button on a screen and hardware button.
But, I don't want to add another screen because some parameter is shared,
So, I use pointers for some widgets and generate/delete the widgets at runtime.
However, when I press the trigger key to change screen during pressing the button on the screen and release the button after the screen has changed, the program has crashed.
I think that the program try to call "Button::handleClickEvent" of the button that has already deleted but failed, it has crashed.
Here's a some sample code.
class sampleScreen {
~~~~~~~~~~
virtual void setupScreen();
~~~~~~~~~~
void buttonPressed();
void triggerKeyPressed();
void switchScreen();
~~~~~~~~~~
Button* button;
~~~~~~~~~~
}
sampleScreen::setupScreen() {
button = new Button();
~~~~~~~~~~
add(*button);
getRootContainer().invalidate();
}
void sampleScreen::buttonPressed() {
switchScreen();
}
void sampleScreen::triggerKeyPressed() {
switchScreen();
}
void sampleScreen::switchScreen() {
remove(*button);
delete button;
getRootContainer().invalidate();
}If there is a way to unresister to listen click event manually when the program switches screen.
Do you know how to do this ? Or should I change plan ?