accepting "Enter" from a wxTextCtrl Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
forrestcupp
Earned some good credits
Earned some good credits
Posts: 102
Joined: Thu Dec 28, 2006 5:12 pm
Location: Indiana, US

accepting "Enter" from a wxTextCtrl

Post by forrestcupp »

I have created a small program that accepts a name from a one line wxTextCtrl. I have a button next to it with a function to accept the input from the wxTextCtrl when clicked. When I enter text in the box and press Enter, it just moves the focus to the button.

How can I set it up so that pressing Enter will go to the function to accept the input instead of just moving the focus?
timg
Earned some good credits
Earned some good credits
Posts: 148
Joined: Mon Jan 23, 2006 6:52 pm

Post by timg »

Be sure you create your wxTextCtrl with the wxTE_PROCESS_ENTER style, then add this:

Code: Select all

	EVT_TEXT_ENTER(ID_TEXTCTRL, myFrame::OnEnter)
To your EVENT_TABLE, of course changing the ID to your textctrl's ID and the function to whatever function you need.
forrestcupp
Earned some good credits
Earned some good credits
Posts: 102
Joined: Thu Dec 28, 2006 5:12 pm
Location: Indiana, US

Post by forrestcupp »

Thank you. The wxTE_PROCESS_ENTER was what I was missing.

I'm brand new at this, so please bear with my simple questions.
Post Reply