|
From: John L. <jla...@gm...> - 2005-07-18 18:06:33
|
On 7/18/05, The Doctor <the...@bl...> wrote:
> John, please can you confirm if this would work?
>=20
> local popMenu =3D wx.wxMenu()
> -- add normal menu items
> -- to position the menu for a button use local rect =3D
> mybutton.GetRect() to find the bottom left.
> mywindow.PopupMenuXY(popMenu, mouseEvt.GetX(), mouseEvt.GetY())
>=20
> It's an example you sent when I needed to make a popup menu. I got that m=
enu to work with explicit co-ordinates, as I never did get mouseEvt to work=
, it's a nil value that can't be indexed, according to the error message I =
got.
It shouldn't be nil , maybe a typo. This code shows the popup menu for
a right down mouse event with control down and for positioning below a
button. Again, if you can provide the simplest full example of some
code I would appreciate it since I wouldn't have to write it from
scratch.
function main()
frame=3Dwx.wxFrame(wx.wxNull,-1,"Frame",wx.wxDefaultPosition,wx.wxSize(=
400,400))
popMenu =3D wx.wxMenu()
popMenu:Append(11, "Menu Item")
=20
panel =3D wx.wxPanel(frame, -1)
=20
textCtrl =3D wx.wxTextCtrl(panel, -1, "", wx.wxPoint(5,5),
wx.wxSize(300, 200))
function textRightDown(event)
if (event:ControlDown()) then=20
textCtrl:PopupMenu(popMenu, event:GetPosition())
end
end
textCtrl:ConnectEvent(-1, wx.wxEVT_RIGHT_DOWN, textRightDown)
=20
button =3D wx.wxButton(panel, 12, "Button", wx.wxPoint(5, 210))
function buttonDown(event)
local width, height =3D button:GetSize()
button:PopupMenuXY(popMenu, 0, height)
event:Skip()
end
button:ConnectEvent(12, wx.wxEVT_COMMAND_BUTTON_CLICKED, buttonDown)
=20
frame:Centre()
frame:Show(wx.TRUE)
end
main()
> I really need help here, there is no documentation, and nothing at all on=
Google. This is like shooting at a tiny hole in a distant wall, while wear=
ing a blindfold, and it's probably easier to pick locks...
The docs, for now, are the Import/*.i files in the source code
download. Look through them to see what is wrapped and what isn't. It
should mostly follow the wxWidgets manual. I think in the future we
can try to make it compatible to wxPython since wxLua has similiar
constraints and functions need to be reworked in similiar ways. (eg.
you can't return values from the input to functions, like
wxWindow::GetSize(int *width, int *height), but rather return both of
them as shown in the code above.)
Regards,
John Labenski
|