capture wxglcanvas mouseevent
BlitzMax Forums/Brucey's Modules/capture wxglcanvas mouseevent
| ||
hi there,i am new to wx and wonder how to capture then glcanvas mouse event,do i need to define a wxmouseevent or what?i want to capture mousemove / mouse hit when the mouse act in the glcanvas(maxgui is easy to do this). thanks for help!! |
| ||
This is basically how my wxGLCanvas wrapper does it: 1. Extend the base type Type TCanvas Extends wxGLCanvas 2. Connect up the events you want to see in OnInit() Connect(Id,wxEVT_MOTION, _OnMouseMove) Connect(Id,wxEVT_LEFT_DCLICK, _OnMouseDown) Connect(Id,wxEVT_LEFT_DOWN, _OnMouseDown) Connect(Id,wxEVT_RIGHT_DOWN, _OnMouseDown) Connect(Id,wxEVT_MIDDLE_DOWN, _OnMouseDown) Connect(Id,wxEVT_LEFT_UP, _OnMouseUp) Connect(Id,wxEVT_RIGHT_UP, _OnMouseUp) Connect(Id,wxEVT_MIDDLE_UP, _OnMouseUp) Connect(Id,wxEVT_MOUSEWHEEL, _OnMouseWheel) Where Id is the ID you used to create the Gadget ie... GetID() 3. Create your MouseDown/Up etc functions Function _OnMouseDown(_event:wxEvent) TCanvas(_event.parent).OnMouseDown(wxMouseEvent(_event)) End Function Function _OnMouseMove(_event:wxEvent) TCanvas(_event.parent).OnMouseMove(wxMouseEvent(_event)) End Function Function _OnMouseUp(_event:wxEvent) TCanvas(_event.parent).OnMouseUp(wxMouseEvent(_event)) End Function 4. And your Methods: Method OnMouseDown(_event:wxMouseEvent) Local button:Int = _event.GetButton() ' Your custom code here _event.Skip() End Method Method OnMouseMove(_event:wxMouseEvent) Local x:Int = _event.GetX() Local y:Int = _event.GetY() ' Your custom code here _event.Skip() End Method Method OnMouseUp(_event:wxMouseEvent) Local button:Int = _event.GetButton() ' Your custom code here _event.Skip() End Method Here is a decent place to start... |
| ||
thank man,will try this later! i really want to find some tutorials about wxEvent,but it's not easy... |