how to create mouse events?

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
iozk
Experienced Solver
Experienced Solver
Posts: 50
Joined: Fri Aug 07, 2009 2:22 pm

how to create mouse events?

Post by iozk » Wed Mar 03, 2010 8:44 pm

hi for draw how i make the mouse events?

xin.songtao
Experienced Solver
Experienced Solver
Posts: 86
Joined: Wed Apr 18, 2007 6:10 am
Location: Shanghai China

Post by xin.songtao » Thu Mar 04, 2010 3:21 am

from: Shanghai China
language: C++/C
platform:MSW\MacOS\Linux
Email: [email protected]

iozk
Experienced Solver
Experienced Solver
Posts: 50
Joined: Fri Aug 07, 2009 2:22 pm

Post by iozk » Fri Mar 05, 2010 5:12 pm

i write this


BEGIN_EVENT_TABLE(SketchWindow, wxWindow)
EVT_LEFT_DOWN(ID_MOUSE_LDOWN, SketchWindow::OnLeftDown)
EVT_LEFT_UP(ID_MOUSE_LUP, SketchWindow::OnLeftUp)
EVT_MOTION(ID_MOUSE_MOVE, SketchWindow::OnMotion)
EVT_SIZE(ID_SIZE, SketchWindow::OnSize)
EVT_IDLE(ID_IDLE, SketchWindow::OnIdle)
EVT_PAINT(ID_PAINT, SketchWindow::OnPaint)

END_EVENT_TABLE()

and give me errors
Error 3 error C2466: Can not allocate an array of constant size 0 c: \ users \ Oscar \ documents \ visual studio 2008 \ projects \ myappw \ myappw \ draw.h 41

Error 3 error C2466: Can not allocate an array of constant size 0 c: \ users \ Oscar \ documents \ visual studio 2008 \ projects \ myappw \ myappw \ draw.h 41

Error 6 error C2440: 'static_cast' : no se puede realizar la conversión de 'const int *' a 'wxMouseEventFunction' c:\users\oscar\documents\visual studio 2008\projects\myappw\myappw\draw.h 42

and it all

JimFairway
wxWorld Domination!
wxWorld Domination!
Posts: 1059
Joined: Sun Dec 30, 2007 6:40 pm
Location: Canada

Post by JimFairway » Fri Mar 05, 2010 6:18 pm

Hi,
It looks like you've put those statements into your .h file, they should be in your .cpp file.

They are not declarations, so they shouldn't be in your class definition. In the .h file:

Code: Select all

class SketchWindow : public wxWindow
{
 // declare the event handlers, as follows:
   void OnLeftUp(wxMouseEvent &event); 
// declare the other handlers (OnLeftUp etc.. similar to line above)
   DECLARE_EVENT_TABLE();
};
Then in the.cpp file:

Code: Select all

BEGIN_EVENT_TABLE(SketchWindow, wxWindow)
EVT_LEFT_DOWN(ID_MOUSE_LDOWN, SketchWindow::OnLeftDown)
EVT_LEFT_UP(ID_MOUSE_LUP, SketchWindow::OnLeftUp)
EVT_MOTION(ID_MOUSE_MOVE, SketchWindow::OnMotion)
EVT_SIZE(ID_SIZE, SketchWindow::OnSize)
EVT_IDLE(ID_IDLE, SketchWindow::OnIdle)
EVT_PAINT(ID_PAINT, SketchWindow::OnPaint)

END_EVENT_TABLE()

Jim
OS: Vista SP1, wxWidgets 2.8.7.

Post Reply