Bug #3882
closed
WSpinBox onChange is not working right
Added by Torsten Schulz about 10 years ago.
Updated about 10 years ago.
Description
When I use the onChange event, it should be fired when I click the up/down buttons or when I change the values with the keyboard.
But the change with the keyboard seems to be fired at the wrong time: Before the value is changed. I become the old value when I type in the values.
Tested with firefox and chrome on windows, mac and linux.
- Status changed from New to InProgress
- Assignee set to Benoit Daccache
- Target version set to 3.3.4
Hey,
The change event as well as the valueChanged event is not fired on keypress but only when the focus is changed.
These two events works well with the following code.
sb->valueChanged().connect(std::bind([=](double val) {
std::cerr << "Value changed : " << val << std::endl;
}, std::placeholders::_1));
sb->changed().connect(std::bind([=]() {
std::cerr << "Value changed : " << sb->text() << std::endl;
}));
Can you provide us an example where it fails ?
Regards,
Benoit
Hi,
I made it with this line:
fBuyData.sellSizeField->changed().connect(boost::bind(&MyGameProduction::StockView::_showPrice, this, fBuyData));
...
void MyGameProduction::StockView::_showPrice(MyGameProduction::StockView::StockSellData aBuyData)
{
aBuyData.priceField->setText("bla bla");
}
And here the setText isn't executed on changing the value by pressing keys, but when I leave the WSpinBox.
Regards
Torsten
Hey,
Could you try to listen to the Wt::WLineEdit::textInput() signal ? ( which is part of the latest git version )
Benoit
Hi Benoit,
I did try and it is working.
But only, because I didn't check it: Did you change the documentation too? Because I understand the changed() like the event is fired on text input too, not on leaving.
Greetings
Torsten
- Status changed from InProgress to Resolved
Indeed it was not mentioned.
Thank you!
Benoit
- Status changed from Resolved to Closed
Also available in: Atom
PDF