Is there a way to reverse a call to WDialog:rejectWhenEscapePressed()?
Added by Steve Drake over 11 years ago
After I have called rejectWhenEscapePressed() so that my WDialog is dismissed when the user presses Escape, is there a way to later 'reverse' the effect so that if the user presses Escape it does not dismiss the dialog?
(I have a dialog box that has a Next button and I am changing the contents of the dialog each time the user clicks Next. When the user gets to the last step, I no longer want him to be able to press Escape to dismiss the dialog.)
I am currently using Wt 3.2.1.
Steve
Replies (3)
RE: Is there a way to reverse a call to WDialog:rejectWhenEscapePressed()? - Added by Wim Dumon over 11 years ago
Can you test if this works and send a patch back? :-) Or else you can choose not to use rejectWhenEscapePressed() but manage these connections in your own code.
void WDialog::rejectWhenEscapePressed(bool enable)
{
if (enable) {
escapeConnection1_ = WApplication::instance()->globalEscapePressed()
.connect(this, &WDialog::reject);
escapeConnection2_ = impl_->escapePressed().connect(this, &WDialog::reject));
} else {
escapeConnection1_.disconnect();
escapeConnection2_.disconnect();
}
}
RE: Is there a way to reverse a call to WDialog:rejectWhenEscapePressed()? - Added by Steve Drake over 11 years ago
Yes, that worked. Thank you! Attached are two patch files (for version 3.2.1).
Steve
0001-wt-3.2.1-add-wdialog-esc-arg.patch (559 Bytes) 0001-wt-3.2.1-add-wdialog-esc-arg.patch | patch 1 (WDialog) | ||
0002-wt-3.2.1-add-wdialog-esc-arg.patch (718 Bytes) 0002-wt-3.2.1-add-wdialog-esc-arg.patch | patch 2 (WDialog.C) |
RE: Is there a way to reverse a call to WDialog:rejectWhenEscapePressed()? - Added by Wim Dumon over 11 years ago
Thank you for verifying. I'll see to it that the patch makes it to the main branch.
Wim.