← Back to team overview

kicad-developers team mailing list archive

Re: ESC key and dialogs

 

Dick Hollenbeck wrote:
2) Click on the Event Handlers tab, and put a check mark into the first box, which should be wxEVT_INIT_DIALOG. This will create a function called OnInitDialog() in the dialog class.

3) Make sure at least one button has a given name (rather than an automatically generated name) by entering that name into the "Name" field associated with the button. Let's say that button name is, for example, m_CloseButton. Save the project and this regenerates the C++ code.

4) In the C++ code make sure your OnInitDialog() function has a line with the "SetFocus()" call, like this:

void dialog_freeroute_exchange::OnInitDialog( wxInitDialogEvent& event )
{
m_CloseButton->SetFocus(); // <----add this line


////@begin wxEVT_INIT_DIALOG event handler for ID_DIALOG_FREEROUTE_EXCHANGE in dialog_freeroute_exchange.
// Before editing this code, remove the block markers.
event.Skip();
////@end wxEVT_INIT_DIALOG event handler for ID_DIALOG_FREEROUTE_EXCHANGE in dialog_freeroute_exchange.
}



A simpler alternative to using OnInitDialog() that seems to work is to simply set the focus in the dialog's constructor, outside the DialogBlocks markers:

m_CloseButton->SetFocus(); // <----add this line to BOTTOM of dialog window's constructor



Again, pick any button you want for the initial focus, seems not to matter.


Dick







References