Hot Door CORE Forum

Full Version: setDoubleClickCallback not working for label widgets
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm trying to set a double-click callback for a Label widget, but it doesn't get called. Mine contains an image, but the behavior can be easily reproduced in the panel sample project. Add these lines to the document name label definition:


Code:
this->__docPanelNameLabel.setDoubleClickCallback(HDI_CORE_CALLBACK(panel::Plugin, this, __doubleclickTestCB));
this->__docPanelNameLabel.setClickCallback(HDI_CORE_CALLBACK(panel::Plugin, this, __clickTestCB));

Now add these two callbacks containing any do-nothing code:

Code:
void panel::Plugin::__doubleclickTestCB(){
int i = 0;
}
void panel::Plugin::__clickTestCB(){
int i = 0;
}

Add breakpoints to each callback, run and test by clicking and double-clicking the label. Double-click never gets called, but instead calls the click callback twice. I tried this on a Button widget with the same results.

Is there something else that needs to be set to recognize a double click?

Thanks for any advice.
As of CORE 0.8.0, labels still don't honor a double-click callback. Someone may have a better option, but for now here's my workaround:

At the end of the postStartup event I set a global Time variable clickTime to Time:Current(true).

I replaced the label's setTextField() function with setClickCallback. The callback begins with this: 

Code:
hdi::core::Time t = hdi::core::Time::Current(true);
double secs1 = t.secondsSinceMidnight();
double secs2 = this->clickTime.secondsSinceMidnight();
this->clickTime = t;
    if ((secs3 > .3) || (secs1 < secs2)){
    // single-click code here
    this->myTextField.focus();
    return;
}
// double-click code goes below

The code accounts for people working past midnight.

I hope others can benefit from this, and that anyone with a better option will share it here.