From: Steve K. <ha...@ya...> - 2006-05-29 10:31:26
|
Hi everyone, I am playing with the sample htmlwin.wx.lua. What I want is to catch the event frm the object embeded in the html window. So far, failled :-) What I did is replace the text box widgets with a button, with an ID and then use ConnectEvent as normal frame:ConnectEvent(button_ID, wx.wxEVT_BUTTON_CLICKED, OnCLickFunc) (Still use version 2.6.2.0 so ConnectEvent is right ) it seems the event is not fired, or not traverse upward to the frame. Even I use html:ConnectEvent; not work as well. How can I make it work or is it impossible? Note: The similar work in c++ though Thanks in advance Cheers, S.KIEU --------------------------------- On Yahoo!7 Socceroos Central: Latest news, schedule, blogs and videos. |
From: John L. <jla...@gm...> - 2006-05-29 22:07:34
|
On 5/29/06, Steve Kieu <ha...@ya...> wrote: > I am playing with the sample htmlwin.wx.lua. What I want is to catch the > event frm the object embeded in the html window. So far, failled :-) > > What I did is replace the text box widgets with a button, with an ID and > then use ConnectEvent as normal > > frame:ConnectEvent(button_ID, wx.wxEVT_BUTTON_CLICKED, OnCLickFunc) > (Still use version 2.6.2.0 so ConnectEvent is right ) > > it seems the event is not fired, or not traverse upward to the frame. Eve= n I > use html:ConnectEvent; not work as well. > > How can I make it work or is it impossible? > > Note: The similar work in c++ though Can you post a little bit of code to show how it should work and what I should expect to see based on your C++ tests. I have never used the HTML widget in lua or C++. Thanks, John Labenski |
From: Steve K. <ha...@ya...> - 2006-05-30 01:12:04
|
Hi, I have a minimum simple script to show as below: frame=wx.wxFrame(wx.wxNull, 10001, "test") --frame:ConnectEvent(10001, wx.wxEVT_ENTER_WINDOW, function (event) print"Enter work" end) --frame:ConnectEvent(10001, wx.wxEVT_LEAVE_WINDOW, function (event) print"Leave not work" end) --not work --frame:ConnectEvent(10001, wx.wxEVT_MOTION, function (event) print"Motion Work" end) --frame:ConnectEvent(10001, wxEVT_LEFT_DCLICK, function (event) print"Not work" end) --frame:ConnectEvent(10001, wxEVT_LEFT_DOWN, function (event) print"Left down not work" end) --frame:ConnectEvent(10001, wxEVT_LEFT_UP ,function (event) print"Left up not work" end) --frame:ConnectEvent(10001, wxEVT_RIGHT_DCLICK ,function (event) print"Right dclick not work" end) --frame:ConnectEvent(-1, wxEVT_RIGHT_DOWN ,function (event) print"Right down not work" end) --frame:ConnectEvent(-1, wxEVT_RIGHT_UP ,function (event) print"Right up not work" end) frame:Center() frame:Show(true) Pls note that the above script, the equivalent C++ work as expected. I have tested it using Dialogblocks; add one frame and add the event accordingly. This one is not related to html window at all And the HTML window; as you suspect from the above one; it work with wxEVT_COMMAND_BUTTON_CLICKED but not with wxEVT_BUTTON_CLICK or wxEVT_LEFT_DCLICK. I have not tested it with another kind of event. frame = nil html = nil htmlTextPage = [[<html> <head> <title>Not working</title> </head> <body> <h3>wxHtmlWidgetCell demonstration</h3> There are three bound widgets below. <hr> <center> <lua text="first widget" x=100 y=70> </center> </body> </html>]] function main() -- create the frame window frame = wx.wxFrame( wx.wxNull, wx.wxID_ANY, "HtmlWindow Demo", wx.wxDefaultPosition, wx.wxSize(450, 450), wx.wxDEFAULT_FRAME_STYLE ) -- create a simple file menu -- THIS WORKS -- frame:ConnectEvent(30000, wx.wxEVT_COMMAND_BUTTON_CLICKED, function(event) -- wx.wxMessageBox("Clicked me") end -- -- ) --THIS NOT WORK frame:ConnectEvent(30000, wx.wxEVT_LEFT_DCLICK, function(event) wx.wxMessageBox("Clicked me") end ) -- create the html window html = wx.wxLuaHtmlWindow(frame, 15000) html.OnSetTitle = function(self, title) frame.Title = frame.Title.." - "..title end -- when a lua custom tag is parsed in the html, this event handler -- will be invoked wx.wxGetBaseApp():ConnectEvent(wx.wxID_ANY, wx.wxEVT_HTML_TAG_HANDLER, function (event) CreateBoundWindow(event) end) -- set the frame window and status bar html:SetRelatedFrame(frame, "wxHtmlWindow wxLua Sample : %s") html:SetRelatedStatusBar(1) -- load the document html:SetPage(htmlTextPage) -- html:LoadPage("testpage.html") -- show the frame window wx.wxGetBaseApp().TopWindow = frame frame:Show(true) end function CreateBoundWindow(event) local ax, ay local rc, fl = 0 -- parse the X parameter in the custom lua tag rc, ax = event.HtmlTag:GetParamAsInt("X") -- parse the Y parameter rc, ay = event.HtmlTag:GetParamAsInt("Y") -- if there is a float tag set the float if event.HtmlTag:HasParam("FLOAT") then fl = ax end -- create the control to embed local parent = event.HtmlParser.Window if parent then -- local wnd = wx.wxTextCtrl( parent, -- wx.wxID_ANY, -- event.HtmlTag:GetParam("TEXT"), -- wx.wxPoint(0, 0), -- wx.wxSize(ax, ay), -- wx.wxTE_MULTILINE ) -- -- show the control local wnd = wx.wxButton( parent, 30000, event.HtmlTag:GetParam("TEXT"), wx.wxPoint(0, 0), wx.wxSize(ax, ay) ) -- show the control wnd:Show(true) -- create the container widget cell local widget = wx.wxHtmlWidgetCell(wnd, fl) -- insert the cell into the document event.HtmlParser:OpenContainer():InsertCell(widget) event:SetParseInnerCalled(false) end end main() Can you post a little bit of code to show how it should work and what I should expect to see based on your C++ tests. I have never used the HTML widget in lua or C++. Sorry the code is a bit too long :-) Cheers, S.KIEU --------------------------------- On Yahoo!7 Answers: Real people ask and answer questions on any topic. |
From: Steve K. <ha...@ya...> - 2006-05-30 01:19:17
|
OOPS My mistake it should prefixed with wx. So most of them works but not wxEVT_LEAVE_WINDOW frame=wx.wxFrame(wx.wxNull, 10001, "test") --frame:ConnectEvent(10001, wx.wxEVT_ENTER_WINDOW, function (event) print"Enter work" end) frame:ConnectEvent(10001, wx.wxEVT_LEAVE_WINDOW, function (event) print"Leave not work" end) --not work --frame:ConnectEvent(10001, wx.wxEVT_MOTION, function (event) print"Motion Work" end) --frame:ConnectEvent(10001, wx.wxEVT_LEFT_DCLICK, function (event) print"work" end) --frame:ConnectEvent(10001, wx.wxEVT_LEFT_DOWN, function (event) print"Left down work" end) --frame:ConnectEvent(10001, wx.wxEVT_LEFT_UP ,function (event) print"Left up work" end) --frame:ConnectEvent(10001, wx.wxEVT_RIGHT_DCLICK ,function (event) print"Right dclick work" end) --frame:ConnectEvent(-1, wx.wxEVT_RIGHT_DOWN ,function (event) print"Right work" end) --frame:ConnectEvent(-1, wx.wxEVT_RIGHT_UP ,function (event) print"Right up work" end) frame:Center() frame:Show(true) For the HTMLWIndow I think the COMMAND EVENT works but not for mouse event which is natural for a button, thus I think it is ok Sorry for a big noise. :-) ANyway the wx.wxEVT_LEAVE_WINDOW not work which I do not understand yet.. John Labenski <jla...@gm...> wrote: On 5/29/06, Steve Kieu wrote: > I am playing with the sample htmlwin.wx.lua. What I want is to catch the > event frm the object embeded in the html window. So far, failled :-) > > What I did is replace the text box widgets with a button, with an ID and > then use ConnectEvent as normal > > frame:ConnectEvent(button_ID, wx.wxEVT_BUTTON_CLICKED, OnCLickFunc) > (Still use version 2.6.2.0 so ConnectEvent is right ) > > it seems the event is not fired, or not traverse upward to the frame. Even I > use html:ConnectEvent; not work as well. > > How can I make it work or is it impossible? > > Note: The similar work in c++ though Can you post a little bit of code to show how it should work and what I should expect to see based on your C++ tests. I have never used the HTML widget in lua or C++. Thanks, John Labenski ------------------------------------------------------- All the advantages of Linux Managed Hosting--Without the Cost and Risk! Fully trained technicians. The highest number of Red Hat certifications in the hosting industry. Fanatical Support. Click to learn more http://sel.as-us.falkag.net/sel?cmd=lnk&kid7521&bid$8729&dat1642 _______________________________________________ Wxlua-users mailing list Wxl...@li... https://lists.sourceforge.net/lists/listinfo/wxlua-users S.KIEU --------------------------------- On Yahoo!7 360°: Your own space to share what you want with who you want! |
From: John L. <jla...@gm...> - 2006-05-30 09:13:57
|
On 5/29/06, Steve Kieu <ha...@ya...> wrote: > > OOPS My mistake it should prefixed with wx. > > So most of them works but not wxEVT_LEAVE_WINDOW > > frame=wx.wxFrame(wx.wxNull, 10001, "test") > --frame:ConnectEvent(10001, wx.wxEVT_ENTER_WINDOW, function (event) > print"Enter work" end) > frame:ConnectEvent(10001, wx.wxEVT_LEAVE_WINDOW, function (event) > print"Leave not work" end) --not work > --frame:ConnectEvent(10001, wx.wxEVT_MOTION, function (event) > print"Motion Work" end) > --frame:ConnectEvent(10001, wx.wxEVT_LEFT_DCLICK, function (event) > print"work" end) > --frame:ConnectEvent(10001, wx.wxEVT_LEFT_DOWN, function (event) print"Left > down work" end) > --frame:ConnectEvent(10001, wx.wxEVT_LEFT_UP ,function (event) print"Left up > work" end) > --frame:ConnectEvent(10001, wx.wxEVT_RIGHT_DCLICK ,function (event) > print"Right dclick work" end) > --frame:ConnectEvent(-1, wx.wxEVT_RIGHT_DOWN ,function (event) print"Right > work" end) > --frame:ConnectEvent(-1, wx.wxEVT_RIGHT_UP ,function (event) print"Right up > work" end) > frame:Center() > frame:Show(true) > For the HTMLWIndow I think the COMMAND EVENT works but not for mouse event > which is natural for a button, thus I think it is ok > > Sorry for a big noise. :-) > > ANyway the wx.wxEVT_LEAVE_WINDOW not work which I do not understand yet.. Events like mouse and wxEVT_LEAVE_WINDOW need to be connected directly to the window. The rule is that if the event is not derived from a wxCommandEvent it won't travel up the event handler chain. You can also tell by the event macro signature, for example EVT_LEAVE_WINDOW(func) doesn't take an id. Try: button:Connect[Event](10001, wxEVT_LEAVE_WINDOW, function(event) print("Bye.") end) Or button:Connect[Event](wx.wxID_ANY, wxEVT_LEAVE_WINDOW, function(event) print("Bye.") end) The latter may be required for some reason, that is a wxWidgets issue however. -John Labenski |
From: Steve K. <ha...@ya...> - 2006-05-30 21:21:12
|
Thanks for your reply. Just abit of adamant, why the following code in c++ works as expected? #include "wx/wx.h" #include "wx/frame.h" class test: public wxFrame { DECLARE_CLASS( test ) DECLARE_EVENT_TABLE() public: test( wxWindow* parent, wxWindowID id = -1, const wxString& caption = _("Test")); void OnLeaveWindow( wxMouseEvent& event ); }; IMPLEMENT_CLASS( test, wxFrame ) // Is the following equivalent to frame:ConnectEvent(wx.wxEVT_LEAVE_WINDOW, OnLeaveWindow) ? BEGIN_EVENT_TABLE( test, wxFrame ) EVT_LEAVE_WINDOW( test::OnLeaveWindow ) END_EVENT_TABLE() test::test( wxWindow* parent, wxWindowID id, const wxString& caption ): wxFrame( parent, id, caption){} void test::OnLeaveWindow( wxMouseEvent& event ){ wxMessageBox(_("Leave window in c++; works")); } class ClGUIApp: public wxApp { DECLARE_CLASS( ClGUIApp ) DECLARE_EVENT_TABLE() public: ClGUIApp(); virtual bool OnInit(); virtual int OnExit(); }; DECLARE_APP(ClGUIApp) IMPLEMENT_APP( ClGUIApp ) IMPLEMENT_CLASS( ClGUIApp, wxApp ) BEGIN_EVENT_TABLE( ClGUIApp, wxApp ) END_EVENT_TABLE() ClGUIApp::ClGUIApp(){} bool ClGUIApp::OnInit() { test* mainWindow = new test( NULL, -1 ); mainWindow->SetSize(400,300); mainWindow->Show(true); return true; } int ClGUIApp::OnExit(){ return wxApp::OnExit(); } Cheers, S.KIEU --------------------------------- On Yahoo!7 Socceroos Central: Latest news, schedule, blogs and videos. |
From: John L. <jla...@gm...> - 2006-05-31 03:08:38
|
On 5/30/06, Steve Kieu <ha...@ya...> wrote: > Thanks for your reply. > Just abit of adamant, why the following code in c++ works as expected? > > #include "wx/wx.h" #include "wx/frame.h" class test: public wxFrame { > DECLARE_CLASS( test ) DECLARE_EVENT_TABLE() public: test( wxWindow* parent, > wxWindowID id = -1, const wxString& caption = _("Test")); void > OnLeaveWindow( wxMouseEvent& event ); }; IMPLEMENT_CLASS( test, wxFrame ) // > Is the following equivalent to frame:ConnectEvent(wx.wxEVT_LEAVE_WINDOW, > OnLeaveWindow) ? BEGIN_EVENT_TABLE( test, wxFrame ) EVT_LEAVE_WINDOW( > test::OnLeaveWindow ) END_EVENT_TABLE() test::test( wxWindow* parent, > wxWindowID id, const wxString& caption ): wxFrame( parent, id, caption){} > void test::OnLeaveWindow( wxMouseEvent& event ){ wxMessageBox(_("Leave > window in c++; works")); } class ClGUIApp: public wxApp { DECLARE_CLASS( > ClGUIApp ) DECLARE_EVENT_TABLE() public: ClGUIApp(); virtual bool OnInit(); > virtual int OnExit(); }; DECLARE_APP(ClGUIApp) IMPLEMENT_APP( ClGUIApp ) > IMPLEMENT_CLASS( ClGUIApp, wxApp ) BEGIN_EVENT_TABLE( ClGUIApp, wxApp ) > END_EVENT_TABLE() ClGUIApp::ClGUIApp(){} bool > ClGUIApp::OnInit() { test* mainWindow = new test( NULL, -1 ); > mainWindow->SetSize(400,300); mainWindow->Show(true); return true; } int > ClGUIApp::OnExit(){ return wxApp::OnExit(); } > Cheers, > This is kinda' hard to read. :/ Take the choices.wx.lua sample, add the line to the leave window. frame:SetStatusText("wxEvents from contols will be displayed here", 0) frame:Connect(wx.wxEVT_LEAVE_WINDOW, function(event) print("Hi") end) It works for me. Remember that the frame is mostly hidden by the notebook so you have to find a spot where it's exposed. Try it out for the listbox as well. Yes the EVT_LEAVE_WINDOW( test::OnLeaveWindow ) is similar to wxEvtHandler::Connect. There are some differences however. The Connect function uses a dynamic event table that is processed before (IIRC) the static event table generated with the macro so you have to use event:Skip() to get the default processing to work in some cases. Regards, John Labenski |