From: John L. <jr...@us...> - 2009-10-05 02:51:38
|
Update of /cvsroot/wxlua/wxLua/samples In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv10796/wxLua/samples Modified Files: controls.wx.lua Log Message: Add a few more wxDateTime member functions. Speedup check for wxSpinEvent vs wxScrollEvent in wxLuaEventCallback::OnEvent() Reorder list of lightuserdata keys for LUA_REGISTRYINDEX in wxlstate.h Cleanup in wxLuaStackDialog, remove EnumerateGlobalData() and just treat is as a regular table. Fix ignoring events for controls in controls.wx.lua Index: controls.wx.lua =================================================================== RCS file: /cvsroot/wxlua/wxLua/samples/controls.wx.lua,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** controls.wx.lua 25 Sep 2009 18:47:58 -0000 1.19 --- controls.wx.lua 5 Oct 2009 02:51:29 -0000 1.20 *************** *** 18,21 **** --- 18,23 ---- taskbarIcon = nil -- The wxTaskBarIcon that we install + wxwindowClassInfo = wx.wxClassInfo("wxWindow") + -- wxBitmap to use for controls that need one bmp = wx.wxArtProvider.GetBitmap(wx.wxART_INFORMATION, wx.wxART_TOOLBAR, wx.wxSize(16, 16)) *************** *** 40,47 **** ignoreControls = {} -- Table of { win_id = "win name" } of controls to ignore events from -- IDs for the windows that we show ID_PARENT_SCROLLEDWINDOW = 1000 - ID_EVENT_LISTCTRL = 5000 - ID_CONTROL_LISTCTRL = 5001 ID_ANIMATIONCTRL = 1001 --- 42,52 ---- ignoreControls = {} -- Table of { win_id = "win name" } of controls to ignore events from + -- IDs for controls used by this program + ID_EVENT_LISTCTRL = 5000 + ID_CONTROL_LISTCTRL = 5001 + ID_CLEAR_LOG = 5002 + -- IDs for the windows that we show ID_PARENT_SCROLLEDWINDOW = 1000 ID_ANIMATIONCTRL = 1001 *************** *** 311,314 **** --- 316,325 ---- elseif typ_name == "wxWindow" then s = s..typ_name.."(GetName="..v:GetName()..")" + elseif typ_name == "wxObject" then + local obj_name = "nil" + if v then + obj_name = v:GetClassInfo():GetClassName() + end + s = s..obj_name else s = s..tostring(v) *************** *** 341,355 **** end - -- during shutdown, we nil textCtrl since events are sent and we don't want them anymore - if (not textCtrl) or ignoreEVTs[evtTypeStr] or ignoreControls[event:GetId()] then - event:Skip(skip) - return - end - - --print(evtClassName, wxEVT_TableByType[event:GetEventType()].name) - -- try to figure out where this came from using the GetEventObject() local obj_str = "nil" if event:GetEventObject() then local classInfo = event:GetEventObject():GetClassInfo() if classInfo then --- 352,372 ---- end -- try to figure out where this came from using the GetEventObject() local obj_str = "nil" + local win_id = -100000000 if event:GetEventObject() then + + -- get the window id from the object since some events don't properly set the id. + if event:GetEventObject():IsKindOf(wxwindowClassInfo) then + local win = event:GetEventObject():DynamicCast("wxWindow") + if win then + win_id = win:GetId(); + end + end + + --if win_id ~= event:GetId() then + -- print(string.format("WARNING : wxEvent ID=%d does not match wxWindow ID=%d", event:GetId(), win_id)) + --end + local classInfo = event:GetEventObject():GetClassInfo() if classInfo then *************** *** 360,363 **** --- 377,388 ---- end + -- during shutdown, we nil textCtrl since events are sent and we don't want them anymore + if (not textCtrl) or ignoreEVTs[evtTypeStr] or ignoreControls[event:GetId()] or ignoreControls[win_id] then + event:Skip(skip) + return + end + + --print(evtClassName, wxEVT_TableByType[event:GetEventType()].name) + local s = string.format("%s %s(%s) GetEventObject=%s", wx.wxNow(), evtClassName, evtTypeStr, obj_str) *************** *** 686,690 **** control = wx.wxNotebook(p, ID_NOTEBOOK, ! wx.wxDefaultPosition, wx.wxSize(200,200)) SetupBook(control) --- 711,715 ---- control = wx.wxNotebook(p, ID_NOTEBOOK, ! wx.wxDefaultPosition, wx.wxSize(200,200)) SetupBook(control) *************** *** 912,915 **** --- 937,942 ---- local fileMenu = wx.wxMenu() + fileMenu:Append(ID_CLEAR_LOG, "&Clear log\tCtrl-C", "Clear text in the log window") + fileMenu:AppendSeparator() fileMenu:Append(wx.wxID_EXIT, "E&xit", "Quit the program") *************** *** 925,928 **** --- 952,959 ---- frame:SetStatusText("Welcome to wxLua.") + + frame:Connect(ID_CLEAR_LOG, wx.wxEVT_COMMAND_MENU_SELECTED, + function (event) textCtrl:Clear() end ) + -- connect the selection event of the exit menu item to an -- event handler that closes the window *************** *** 933,938 **** frame:Connect(wx.wxID_ABOUT, wx.wxEVT_COMMAND_MENU_SELECTED, function (event) ! wx.wxMessageBox('This is the "About" dialog of the Controls wxLua sample.\n'.. ! 'Check or uncheck events you want shown.\n'.. wxlua.wxLUA_VERSION_STRING.." built with "..wx.wxVERSION_STRING, "About wxLua", --- 964,969 ---- frame:Connect(wx.wxID_ABOUT, wx.wxEVT_COMMAND_MENU_SELECTED, function (event) ! wx.wxMessageBox('This is the "About" dialog of the Controls wxLua sample.\n\n'.. ! 'Check or uncheck events and windows you want logged.\n'.. wxlua.wxLUA_VERSION_STRING.." built with "..wx.wxVERSION_STRING, "About wxLua", *************** *** 1024,1028 **** end elseif win_id == ID_CONTROL_LISTCTRL then - print(sel[n][2], type(sel[n][2])) if img == 0 then ignoreControls[tonumber(sel[n][2])] = true --- 1055,1058 ---- |