Project

General

Profile

Is there a way to reverse a call to WDialog:rejectWhenEscapePressed()?

Added by Steve Drake about 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 about 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 Wim Dumon about 11 years ago

Thank you for verifying. I'll see to it that the patch makes it to the main branch.

Wim.

    (1-3/3)