Hi!
In my project I need to use an Event Handlar personalized for some TextCtrl, and I use this code:
MyEvtHandlerOnTime *evt = new MyEvtHandlerOnTime( l_new->u.c_ptrtext, &l_new->c_wxvalue);
l_new->u.c_ptrtext->PushEventHandler( evt);
When I close the dialog, How can I pop all Event Handler in one time?
Thanks.
Stefania
wxEvtHandler personalized Topic is solved
Re: wxEvtHandler personalized
It's not very clear what your aim is; try to catch wxCloseEvent for the dialog. See wxDialog docs.
- eranon
- Can't get richer than this
- Posts: 867
- Joined: Sun May 13, 2012 11:42 pm
- Location: France
- Contact:
Re: wxEvtHandler personalized
Maybe you could be interested by http://wiki.wxwidgets.org/Custom_Events_Tutorial ; but maybe the existing events suffice for what you want to achieve... Difficult to say from your post...
[Ind. dev. - wxWidgets 3.0/3.1 under "Win 7 64-bit, TDM64-GCC" + "OS X 10.9, LLVM Clang"]
Re: wxEvtHandler personalized
Hi!
This is my class fro wxEvtHandler:
class MyEvtHandlerOnTime : public wxEvtHandler
{
public:
MyEvtHandlerOnTime( wxTextCtrl *text, wxString *val) { c_text = text; c_val = val;}
void OnKeyDown (wxKeyEvent& event) {
.....
return;
}
private:
wxTextCtrl *c_text;
wxString *c_val;
DECLARE_EVENT_TABLE();
};
BEGIN_EVENT_TABLE(MyEvtHandlerOnTime, wxEvtHandler)
EVT_KEY_DOWN( MyEvtHandlerOnTime::OnKeyDown)
END_EVENT_TABLE()
In my code I wrote:
m_text = new wxTextCtrl( itemPanel153, ID_Mac_dalle4_6, wxEmptyString, wxDefaultPosition, wxSize(60, -1), 0 );
MyEvtHandlerOnTime *evt = new MyEvtHandlerOnTime(m_text, c_wxvalue);
m_text->PushEventHandler( evt);
.
.
.
When I close dialog I wrote:
m_text->PopEventHandler(true);
but when I close dialog I have wxWidget Debug Alert:
..\..\src\common\wincmn.cpp(468): assert "GetEventHandler() == this" failed in wxWindowsBase::~wxWindowsBase(): any pushed event handler have been removed
What is the problem?
This is my class fro wxEvtHandler:
class MyEvtHandlerOnTime : public wxEvtHandler
{
public:
MyEvtHandlerOnTime( wxTextCtrl *text, wxString *val) { c_text = text; c_val = val;}
void OnKeyDown (wxKeyEvent& event) {
.....
return;
}
private:
wxTextCtrl *c_text;
wxString *c_val;
DECLARE_EVENT_TABLE();
};
BEGIN_EVENT_TABLE(MyEvtHandlerOnTime, wxEvtHandler)
EVT_KEY_DOWN( MyEvtHandlerOnTime::OnKeyDown)
END_EVENT_TABLE()
In my code I wrote:
m_text = new wxTextCtrl( itemPanel153, ID_Mac_dalle4_6, wxEmptyString, wxDefaultPosition, wxSize(60, -1), 0 );
MyEvtHandlerOnTime *evt = new MyEvtHandlerOnTime(m_text, c_wxvalue);
m_text->PushEventHandler( evt);
.
.
.
When I close dialog I wrote:
m_text->PopEventHandler(true);
but when I close dialog I have wxWidget Debug Alert:
..\..\src\common\wincmn.cpp(468): assert "GetEventHandler() == this" failed in wxWindowsBase::~wxWindowsBase(): any pushed event handler have been removed
What is the problem?
Re: wxEvtHandler personalized
Code: Select all
..\..\src\common\wincmn.cpp(468): assert "GetEventHandler() == this" failed in wxWindowsBase::~wxWindowsBase(): any pushed event handler have been removed
And what exactly are you doing with the custom event handler? I've never used Push/PopEventHandler and i suspect there is an easier way to achieve what you need.
Use the source, Luke!
Re: wxEvtHandler personalized
I call PopEvtHandler before EndModal(wxID_CANCEL) and I am sure do it for each textCtrl.
With wxWindget 2.8.10 this message does not compare.
I use Pop/Push Event for TextCtrl that I use for time input, I need to format input with hh:mm
The timePickerCtrl does not work fine in my project because I need to have some value not valorized.
Thanks
With wxWindget 2.8.10 this message does not compare.
I use Pop/Push Event for TextCtrl that I use for time input, I need to format input with hh:mm
The timePickerCtrl does not work fine in my project because I need to have some value not valorized.
Thanks
Re: wxEvtHandler personalized
Is this the only path to close the dialog? What happens in the user clicks OK or the close button of the Dialog? Try moving it to the destructor.I call PopEvtHandler before EndModal(wxID_CANCEL) and I am sure do it for each textCtrl.
Use the source, Luke!
- eranon
- Can't get richer than this
- Posts: 867
- Joined: Sun May 13, 2012 11:42 pm
- Location: France
- Contact:
Re: wxEvtHandler personalized
I see in the doc (never used) that the wxTimePickerCtrl allows to pass a validator to its constructor. So, why don't you create your own validator to validate the value(s) the way you want ?
[Ind. dev. - wxWidgets 3.0/3.1 under "Win 7 64-bit, TDM64-GCC" + "OS X 10.9, LLVM Clang"]