Thread: Detecting mouse events in the SQL grid
Hi,
I'm trying to add some additional mouse event detection into the SQL grid, but I'm not succeeding. Besides pgAdmin, also wxWidgets is new to me, so I'm probably missing something obvious...
The grid was already detecting EVT_MOUSEWHEEL, so I tried to use that as my guideline:
In ctlSQLGrid.h for the ctlSQLGrid class I added two private functions on the bottom:
private:
void OnCopy(wxCommandEvent &event);
void OnMouseWheel(wxMouseEvent &event);
void OnMouseLeftDown(wxMouseEvent &event);
void OnMouseLeftUp(wxMouseEvent &event);
In ctlSQLGrid.cpp I added two events:
BEGIN_EVENT_TABLE(ctlSQLGrid, wxGrid)
EVT_MENU(MNU_COPY, ctlSQLGrid::OnCopy)
EVT_MOUSEWHEEL(ctlSQLGrid::OnMouseWheel)
EVT_LEFT_DOWN(ctlSQLGrid::OnMouseLeftDown)
EVT_LEFT_UP(ctlSQLGrid::OnMouseLeftUp)
END_EVENT_TABLE()
An then in ctlSQLGrid.cpp I defined the functions e.g. like this:
void ctlSQLGrid::OnMouseLeftUp(wxMouseEvent &event)
{
SetTotals();
}
However, I never hit these functions by clicking the mouse, and I don't understand why. Would really appreciate any advice.
Thanks,
KariK
On Sun, 2013-02-17 at 12:21 -0800, Kari Karkkainen wrote: > Hi, > > I'm trying to add some additional mouse event detection into the SQL grid, but I'm not succeeding. Besides pgAdmin, alsowxWidgets is new to me, so I'm probably missing something obvious... > > The grid was already detecting EVT_MOUSEWHEEL, so I tried to use that as my guideline: > > In ctlSQLGrid.h for the ctlSQLGrid class I added two private functions on the bottom: > private: > void OnCopy(wxCommandEvent &event); > void OnMouseWheel(wxMouseEvent &event); > void OnMouseLeftDown(wxMouseEvent &event); > void OnMouseLeftUp(wxMouseEvent &event); > > In ctlSQLGrid.cpp I added two events: > BEGIN_EVENT_TABLE(ctlSQLGrid, wxGrid) > EVT_MENU(MNU_COPY, ctlSQLGrid::OnCopy) > EVT_MOUSEWHEEL(ctlSQLGrid::OnMouseWheel) > EVT_LEFT_DOWN(ctlSQLGrid::OnMouseLeftDown) > EVT_LEFT_UP(ctlSQLGrid::OnMouseLeftUp) > END_EVENT_TABLE() > > An then in ctlSQLGrid.cpp I defined the functions e.g. like this: > void ctlSQLGrid::OnMouseLeftUp(wxMouseEvent &event) > { > SetTotals(); > } > > However, I never hit these functions by clicking the mouse, and I don't understand why. Would really appreciate any advice. > Are you sure it's not already dealt with at the window level? -- Guillaume http://blog.guillaume.lelarge.info http://www.dalibo.com
Hi Guillaume,
No, I don't know if it is dealt with at the window level. I also thought that this could be the issue, i.e. that the event is intercepted and handled somewhere else, but I could not find out where that might be. Any advice?
Also, one (probably basic) thing is unclear to me: If I handle this mouse event (or most other input events), do I then prevent the event from being managed by its default handler, which maybe I need to invoke from my event handler to make sure no default behavior is missed?
Thanks,
KariK
From: Guillaume Lelarge <guillaume@lelarge.info>
To: Kari Karkkainen <kari_karkkainen@yahoo.com>
Cc: pgadmin-hackers <pgadmin-hackers@postgresql.org>
Sent: Saturday, February 23, 2013 4:50 PM
Subject: Re: [pgadmin-hackers] Detecting mouse events in the SQL grid
On Sun, 2013-02-17 at 12:21 -0800, Kari Karkkainen wrote:
> Hi,
>
> I'm trying to add some additional mouse event detection into the SQL grid, but I'm not succeeding. Besides pgAdmin, also wxWidgets is new to me, so I'm probably missing something obvious...
>
> The grid was already detecting EVT_MOUSEWHEEL, so I tried to use that as my guideline:
>
> In ctlSQLGrid.h for the ctlSQLGrid class I added two private functions on the bottom:
> private:
> void OnCopy(wxCommandEvent &event);
> void OnMouseWheel(wxMouseEvent &event);
> void OnMouseLeftDown(wxMouseEvent &event);
> void OnMouseLeftUp(wxMouseEvent &event);
>
> In ctlSQLGrid.cpp I added two events:
> BEGIN_EVENT_TABLE(ctlSQLGrid, wxGrid)
> EVT_MENU(MNU_COPY, ctlSQLGrid::OnCopy)
> EVT_MOUSEWHEEL(ctlSQLGrid::OnMouseWheel)
> EVT_LEFT_DOWN(ctlSQLGrid::OnMouseLeftDown)
> EVT_LEFT_UP(ctlSQLGrid::OnMouseLeftUp)
> END_EVENT_TABLE()
>
> An then in ctlSQLGrid.cpp I defined the functions e.g. like this:
> void ctlSQLGrid::OnMouseLeftUp(wxMouseEvent &event)
> {
> SetTotals();
> }
>
> However, I never hit these functions by clicking the mouse, and I don't understand why. Would really appreciate any advice.
>
Are you sure it's not already dealt with at the window level?
--
Guillaume
http://blog.guillaume.lelarge.info
http://www.dalibo.com
--
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers
On Sat, 2013-02-23 at 08:04 -0800, Kari Karkkainen wrote: > Hi Guillaume, > > > No, I don't know if it is dealt with at the window level. I also > thought that this could be the issue, i.e. that the event is > intercepted and handled somewhere else, but I could not find out where > that might be. Any advice? > Well, as you didn't send a patch, I don't know much what you tried. I would add some code in the ctlSQLGrid::OnMouseLeftUp method to log something (either on a message box or on a log file). Just to make sure it got the event. If it didn't, I would try to suppress all mouse event handling in the test window. > Also, one (probably basic) thing is unclear to me: If I handle this > mouse event (or most other input events), do I then prevent the event > from being managed by its default handler, which maybe I need to > invoke from my event handler to make sure no default behavior is > missed? > AFAIK, if you intercept the event, you deal with it. Then you decide to let the next layer take care of it... or not. It's your choice. -- Guillaume http://blog.guillaume.lelarge.info http://www.dalibo.com