-- try this read the code look at which events are pass which are not
-- note the casting to make connectKeyUpEvent work
-- click on the various elements and type to see which one gets the events
-- I will be gone for a while

frm = wx.wxFrame( wx.NULL, wx.wxID_ANY, "Testing")
pnl = wx.wxPanel(frm, wx.wxID_ANY)
mainSizer = wx.wxBoxSizer( wx.wxVERTICAL)
hsizer =  wx.wxBoxSizer( wx.wxHORIZONTAL)
but = wx.wxButton(pnl, wx.wxID_ANY, 'name')
st1 = wxstc.wxStyledTextCtrl(pnl, wx.wxID_ANY)
st2 = wxstc.wxStyledTextCtrl(pnl, wx.wxID_ANY)

but:Connect(wx.wxID_ANY, wx.wxEVT_CHAR,
    function(event)
        print('char but ', event.KeyCode)
        event:Skip()
    end)

but:Connect(wx.wxID_ANY, wx.wxEVT_CHAR_HOOK,
    function(event)
        print('hook but ', event.KeyCode)
        event:Skip()
    end)

st1:Connect(wx.wxID_ANY, wx.wxEVT_CHAR,
    function(event)
        print('char st1 ', event.KeyCode)
        event:Skip()
    end)

st1:Connect(wx.wxID_ANY, wx.wxEVT_CHAR_HOOK,
    function(event)
        print('hook st1 ', event.KeyCode)
        event:Skip()
    end)

st2:Connect(wx.wxID_ANY, wx.wxEVT_CHAR,
    function(event)
        print('char st2 ', event.KeyCode)
        event:Skip()
    end)

st2:Connect(wx.wxID_ANY, wx.wxEVT_CHAR_HOOK,
    function(event)
        print('hook st2 ', event.KeyCode)
        event:Skip()
    end)

pnl:Connect(wx.wxID_ANY, wx.wxEVT_CHAR,
    function(event)
        print('char pnl ', event.KeyCode)
        event:Skip()
    end)

pnl:Connect(wx.wxID_ANY, wx.wxEVT_CHAR_HOOK,
    function(event)
        print('char pnl ', event.KeyCode)
        event:Skip()
    end)

frm:Connect(wx.wxID_ANY, wx.wxEVT_CHAR,
    function(event)
        print('char frm ', event.KeyCode)
        event:Skip()
    end)

frm:Connect(wx.wxID_ANY, wx.wxEVT_CHAR_HOOK,
    function(event)
        print('hook frm ', event.KeyCode)
        event:Skip()
    end)

pnl:SetSizer(mainSizer)
hsizer:Add(st1, 0,  wx.wxLEFT)
hsizer:Add(st2, 0,  wx.wxRIGHT)
mainSizer:Add(but)
mainSizer:Add(hsizer)
mainSizer:SetSizeHints(pnl)

function CharKeyEvent(event)
    print('up', event.KeyCode)
    event:Skip()
end

function connectKeyUpEvent(win)
    if win then
        win = win:DynamicCast('wxWindow')
        win:Connect(wx.wxID_ANY, wx.wxEVT_KEY_UP, CharKeyEvent)
        local childNode = win:GetChildren():GetFirst()
        while childNode do
            connectKeyUpEvent(childNode:GetData())
            childNode = childNode:GetNext()
        end
    end
end

connectKeyUpEvent(frm)

frm:Show(true)

Andre


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
wxlua-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wxlua-users

Reply via email to