Hello Guest it is December 11, 2019, 07:11:56 PM

Author Topic: Lua Panels and events  (Read 2236 times)

0 Members and 1 Guest are viewing this topic.

Lua Panels and events
« on: August 14, 2014, 01:14:34 AM »
Steve (aka smurph), is there something that is causing mouse events not to work in Lua Panels that are dropped into a screen set?  I have panel that I plan to show an image in, and have event handlers capture the mouse X & Y coordinates on left clicks.  I copied and simplified some code from one of the wizards and dropped it into the script property of the Lua Panel.  The onPaint() event is working, but the onLeftUp() event handler is not.  Is there something blocking events from happening on

Code: [Select]
-- Load the wxLua module, does nothing if running from wxLua, wxLuaFreeze, or wxLuaEdit
package.cpath = package.cpath..";./?.dll;./?.so;../lib/?.so;../lib/vc_dll/?.dll;../lib/bcc_dll/?.dll;../lib/mingw_dll/?.dll;"
require("wx")

-- paint event handler for the frame that's called by wxEVT_PAINT
function onPaint(event)
    -- must always create a wxPaintDC in a wxEVT_PAINT handler
    local dc = wx.wxPaintDC(panel)
    -- call some drawing functions
    dc:DrawRectangle(10, 10, 300, 300);
    dc:DrawRoundedRectangle(20, 20, 280, 280, 20);
    dc:DrawEllipse(30, 30, 260, 260);
    dc:DrawText("A test string", 50, 150);
    dc:delete() -- ALWAYS delete() any wxDCs created when done
end

function onLeftUp (event)
    local mouseX = event.GetX();
    local mouseY = event.GetY();

    mc.mcCntlSetLastError("LEFT CLICK - X: "..tostring(mouseX)..", Y: "..tostring(mouseY));
end

panel = mcLuaPanelParent

-- connect the paint event handler function with the paint event
panel:Connect(wx.wxEVT_PAINT, onPaint)
panel:Connect(wx.wxEVT_LEFT_UP, onLeftUp);

Hmmm... I just tried modifying the original wizard code and it's not showing left clicks either :(  I wonder what I'm missing?


-Freeman
« Last Edit: August 14, 2014, 01:17:01 AM by Analias »
I'm not a complete idiot...
    there are some parts missing.

Offline poppabear

*
  • *
  •  2,233 2,233
  • Briceville, TN, USA
    • View Profile
    • S S Systems, LLC
Re: Lua Panels and events
« Reply #1 on: August 14, 2014, 02:24:44 PM »
Hey freeman,

you don't have to "import" wx as a module it is already in M4.

so just do things like wx.w*************************** (what ever call)

Scott
Commercial Mach3 & Mach 4, Design/Build/Retrofit CNC and Industrial machines.
http://www.ss-systems-llc.com/

Offline smurph

*
  • *
  •  1,161 1,161
  • "That there... that's an RV."
    • View Profile
Re: Lua Panels and events
« Reply #2 on: August 27, 2014, 07:38:20 PM »
I would add a panel on top of the parent panel.  The parent panel actually resides in mach4gui and any click events are going to be eaten by the GUI. 

Steve