how to create mouse events?
how to create mouse events?
hi for draw how i make the mouse events?
-
- Experienced Solver
- Posts: 86
- Joined: Wed Apr 18, 2007 6:10 am
- Location: Shanghai China
have a look at
http://docs.wxwidgets.org/stable/wx_wxm ... mouseevent
http://docs.wxwidgets.org/stable/wx_wxm ... mouseevent
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
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
-
- wxWorld Domination!
- Posts: 1059
- Joined: Sun Dec 30, 2007 6:40 pm
- Location: Canada
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:
Then in the.cpp file:
Jim
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();
};
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.