Octavian Rasnita wrote:
Hi,
I have 2 buttons on a Wx::Dialog window, and I want one of them to be
pressed when I hit enter on a text field, and the other one to be
pressed when I press the escape key.
I have read on the manual page of Wx::Dialog that I can use wxOK, or
wxID_OK, wxCANCEL, or wxID_CANCEL (I didn't understand which of them) in
order to do this, but it doesn't seem to work.
You need wxID_OK/wxID_CANCEL
I have also tried to use SetAffirmativeId() and SetEscapeId() but after
doing that, I couldn't close the dialog with the close button even if I
press it with the space bar.
So I am sure I am doing something wrong. Can you tell me the right way
to do what I want?
I only tried under Mac, but for me: $ok_button->setDefault makes
the button respond to the enter key (it is also displayed correctly
in the UI); as for the dialog not closing: are you calling $event->Skip
from your event handler to allow the default event processing to happen?
HTH
Mattia