I've been playing around with a panel script Freeman had posted, Basically was trying to get an idea what is going on.
Thou have to admit not following all this Lua panel scripting. But did find I could get some basic information and compute some data from mouse events by using mouse down and and mouse up.
Found that the onSize() function is not working correctly
local panel = mcLuaPanelParent
inst = mc.mcGetInstance();
function onPaint (event)
local dc = wx.wxPaintDC(panel);
local image = wx.wxImage();
if (not image:LoadFile('C://Mach3//Bitmaps//MachStdMill//test.png', wx.wxBITMAP_TYPE_PNG)) then
wx.wxLogError("Could not load image from '%s'!", imagePath);
dc:delete();
return;
end
local bitmap = wx.wxBitmap(image);
dc:DrawBitmap (bitmap, 0,0, true);
dc:delete ();
end
function onLeftUp (event)
local mouseXup = event:GetX();
local mouseYup = event:GetY();
local diffX = mouseXup-mouseXdn;
local diffY = mouseYup-mouseYdn;
mc.mcCntlSetLastError(inst,"Mouse Click Up Location is @ X: "..tostring(mouseXup)..", Y: "..tostring(mouseYup));
mc.mcCntlSetLastError(inst,"Difference in X: "..tostring(diffX)..", Y: "..tostring(diffY));
end
function onLeftDown (event)
mouseXdn = event:GetX();
mouseYdn = event:GetY();
mc.mcCntlSetLastError(inst,"Mouse Click Down Location is @ X: "..tostring(mouseXdn)..", Y: "..tostring(mouseYdn));
end
function onSize (event)
local sized = event:GetSize();
local width = event:GetWidth();
local height = event:GetHeight();
mc.mcCntlSetLastError(inst,"Width: "..tostring(width)..", Height: "..tostring(height));
event:skip();
end
panel:Connect(wx.wxEVT_PAINT, onPaint)
panel:Connect(wx.wxEVT_LEFT_UP, onLeftUp);
panel:Connect(wx.wxEVT_LEFT_DOWN, onLeftDown);
panel:Connect(wx.wxEVT_SIZE, onSize);