I tried to use this control in my project.
At the beginning, everything is OK.
But soon I found I cannot handle DOM event.
I want to handle a button event from the DOM.
I used a function named 'AddEventListener', but noting happened.
The following is my code.
- Code: Select all
const int wxID_WEB = 9001;
const int WX_CLICK_EVENT = 999991;
class MyFrame : public wxFrame
{
...
void OnDOMContentLoaded(wxWebEvent& evt);
void OnDOMEvent(wxWebEvent &evt);
...
}
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
...
EVT_WEB_DOMCONTENTLOADED(wxID_WEB, MyFrame::OnDOMContentLoaded)
EVT_WEB_DOMEVENT(wxID_WEB, MyFrame::OnDOMEvent)
...
END_EVENT_TABLE()
void MyFrame::OnDOMContentLoaded(wxWebEvent& evt)
{
wxDOMDocument document = m_browser->GetDOMDocument();
wxDOMElement ele = document.GetElementById(wxT("mybt"));
if (ele.IsOk())
{
ele.SetAttribute(wxT("value"), wxT("Hello"));
ele.AddEventListener(wxT("onclick"), this, WX_CLICK_EVENT, true);
}
}
void MyFrame::OnDOMEvent(wxWebEvent &evt)
{
OutputDebugString(wxT("DOM event!!\n"));
}
The function 'OnDOMEvent' hasnot been called when I click the button.
I hope you answer
Thank you