How to get EVT_TEXT_ENTER in wxNotebookPage 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
lqj1990
In need of some credit
In need of some credit
Posts: 4
Joined: Sun Aug 20, 2017 6:07 pm

How to get EVT_TEXT_ENTER in wxNotebookPage

Post by lqj1990 »

I use wxTextCtrl in a wxNotebookPage. When I want to get the value of wxTextCtrl when input something, I can't trigger the event wxEVT_TEXT_ENTER. I don't know why this happens. Other elements such as wxButton and wxChoice work well when they are put in a wxNotebookPage.

What should I do to trigger wxTextCtrl event in wxNoteBookPage?

Code: Select all

EVT_TEXT_ENTER(wxID_Page, MainFrame::OnChangeText)

MainFrame:MainFrame(){
...
notebook = new wxNotebook(this, ID_NOTEBOOK);
page = new wxNotebookPage(annotation_notebook, ID_PAGE);
notebook->AddPage(page, wxt("page"));
textcontrol = new wxTextCtrl(page, wxID_Page, wxT(""));
....
}

MainFrame::OnChangeTest(){
.....
}
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: How to get EVT_TEXT_ENTER in wxNotebookPage

Post by doublemax »

You need to add the wxTE_PROCESS_ENTER style flag when creating the wxTextCtrl.
Use the source, Luke!
lqj1990
In need of some credit
In need of some credit
Posts: 4
Joined: Sun Aug 20, 2017 6:07 pm

Re: How to get EVT_TEXT_ENTER in wxNotebookPage

Post by lqj1990 »

doublemax wrote:You need to add the wxTE_PROCESS_ENTER style flag when creating the wxTextCtrl.
I try to set the style using textcontrol ->SetExtraStyle(wxTE_PROCESS_ENTER);
But it does not work. The text_enter_event is still not triggered.

The TextCtrl not in the notebookpage work well. So I don't understand why this happens.
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: How to get EVT_TEXT_ENTER in wxNotebookPage

Post by doublemax »

wxTE_PROCESS_ENTER is not an "extra" style. Add it to the "flags" parameter of the constructor:

Code: Select all

textcontrol = new wxTextCtrl(page, wxID_Page, wxT(""), wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER);
Use the source, Luke!
joe31093
Earned a small fee
Earned a small fee
Posts: 12
Joined: Thu Mar 15, 2018 3:06 pm

Re: How to get EVT_TEXT_ENTER in wxNotebookPage

Post by joe31093 »

I am having the same issue. Even with wxTE_PROCESS_ENTER, the enter event is not generated.

If I change the the catch event from wxEVT_TEXT_ENTER to wxEVT_TEXT, I get an event each time I type a character.

Anyone else having this issues?
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: How to get EVT_TEXT_ENTER in wxNotebookPage

Post by doublemax »

I am having the same issue. Even with wxTE_PROCESS_ENTER, the enter event is not generated.
We need more context here.

Is the problem exactly like in the orginal post, i.e. is a wxNoteBook involved?

Which platform and wxWidgets version are you using?

Can you show sample code that demonstrates the problem?
Use the source, Luke!
joe31093
Earned a small fee
Earned a small fee
Posts: 12
Joined: Thu Mar 15, 2018 3:06 pm

Re: How to get EVT_TEXT_ENTER in wxNotebookPage

Post by joe31093 »

Yes, the control is inside of a wxNoteBook.

In the main wxFrame constructor init, the notebook is created and passed to another class that uses it to add the textCtrl.

Code: Select all

ScopeControlFrame::ScopeControlFrame(const wxString& title):wxFrame(NULL, wxID_ANY, title),
m_notebook(new wxNotebook(this, wxID_ANY)),
m_viewWorkflow(this, m_notebook),
...
In the main wxFrame constructor

Code: Select all

this->Bind(wxEVT_TEXT_ENTER, &ScopeControlFrame::OnLaser1PowerPercentChange, this, ID_LASER_1_PERCENT_DISPLAY);
m_notebook->AddPage(m_viewWorkflow.getLayoutPanel(), "System Workflow");
In the m_viewWorkflow class, it creates a wxPanel with the notebook as its parent. The text ctrl is added to panel. id_percentSliderDisplay = ID_LASER_1_PERCENT_DISPLAY

Code: Select all

m_percentSliderDisplay = new wxTextCtrl(layoutPanel, id_percentSliderDisplay, wxT("0.00"), wxDefaultPosition, wxSize(60, -1), wxTE_PROCESS_ENTER | wxTE_RIGHT, numericValueValidator);
I am running on MacOSX 10.12.6 (16G1510), wxWidgets 3.1.1 and Xcode 9.0 (9A235)
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4193
Joined: Sun Jan 03, 2010 5:45 pm

Re: How to get EVT_TEXT_ENTER in wxNotebookPage

Post by PB »

joe31093, sorry for a stupid question, but is the issue really that the control is in the wxNotebook and it works as expected if it is not?

I ask because, wxNotebook aside, it looks like this just recently fixed issue: https://trac.wxwidgets.org/ticket/18206
joe31093
Earned a small fee
Earned a small fee
Posts: 12
Joined: Thu Mar 15, 2018 3:06 pm

Re: How to get EVT_TEXT_ENTER in wxNotebookPage

Post by joe31093 »

It may be the issue you listed above and does not have anything to do with the notebook. Let me see if I can pull the latest code and see if a rebuild resolves the issue. Thanks for sending me the link.

1: To get this fix, do I download "master"?
2: Since I am building everything with Xcode, I just need to copy the source over, is that correct?
joe31093
Earned a small fee
Earned a small fee
Posts: 12
Joined: Thu Mar 15, 2018 3:06 pm

Re: How to get EVT_TEXT_ENTER in wxNotebookPage

Post by joe31093 »

Pulled the fix and rebuilt with Xcode and the issue is fixed.

@PB, thank you for your help.
Post Reply