I want to trigger different actions for single click (selecting the component) and double click (call an editor).
To achieve this I’ve added addMouseListener( this, true); to the constructor of the component.
But in ::mouseDown() I will of course get two mouseDowns for a ::mouseDoubleClick(), but there is no mouseSingleClick(). What’s the way to go to differentiate a single click from a double click?
For now I came up with this:
void GUIPlayModePatchComponent::mouseDoubleClick(const MouseEvent& event) {
std::cout << "Double-Click\n";
stopTimer(); // Cancle pending single click
std::cout << "Single click canceled\n";
}
void GUIPlayModePatchComponent::mouseDown(const MouseEvent& event) {
std::cout << "Starting single click detection!\n";
startTimer(200);
}
void GUIPlayModePatchComponent::timerCallback() {
// Distinguish DoubleClick from single
// When this routine is reached we had a single click
stopTimer();
std::cout << "That was a confirmed single-click\n";
}
Is that the way to go?
kr
Timm
