Hello,
I used to implement wxNotebook in my previous applications, and have used EVT_RIGHT_DOWN(func) to get capture of right clicking on the tab of the wxNotebook, but I cant seem to get it working on wxAuiNotebook.
Any suggestion/solutions will be appreciated.
Thank you
wxAuiNotebook right click?
-
- Earned a small fee
- Posts: 13
- Joined: Mon Jun 26, 2006 9:21 am
-
- Earned a small fee
- Posts: 13
- Joined: Mon Jun 26, 2006 9:21 am
My event handling code for a wxAuiNotebook and wxNotebook
It works on wxNotebook, but does not work on wxAuiNotebook. wxAuiNotebook does not seem to take the right click as an event.
I am using wxWidgets 2.8.0(since I want to use wxAui)
void Mypanel::OnRightClick(wxMouseEvent &e) {
//proceesss my mouse event here
}
BEGIN_EVENT_TABLE(Mypanel,wxAuiNotebook)
EVT_RIGHT_DOWN(Mypanel::OnRightClick)
END_EVENT_TABLE()
It works on wxNotebook, but does not work on wxAuiNotebook. wxAuiNotebook does not seem to take the right click as an event.
I am using wxWidgets 2.8.0(since I want to use wxAui)
void Mypanel::OnRightClick(wxMouseEvent &e) {
//proceesss my mouse event here
}
BEGIN_EVENT_TABLE(Mypanel,wxAuiNotebook)
EVT_RIGHT_DOWN(Mypanel::OnRightClick)
END_EVENT_TABLE()
same problem here...
wx2.8 and visual studio 2005 express
it seems it doesn't get any mouse events.Anyone?
wx2.8 and visual studio 2005 express
it seems it doesn't get any mouse events.
Code: Select all
#ifndef EXTNOTEBOOK_H
#define EXTNOTEBOOK_H
class DLLIMPORT ExtNotebook : public wxAuiNotebook
{
public:
ExtNotebook ();
ExtNotebook (wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxAUI_NB_DEFAULT_STYLE);
virtual ~ExtNotebook();
private:
DECLARE_EVENT_TABLE()
void OnMouse (wxMouseEvent & event);
};
#endif
Code: Select all
#include "wx_pch.h"
BEGIN_EVENT_TABLE(ExtNotebook, wxAuiNotebook)
EVT_RIGHT_DOWN (ExtNotebook::OnMouse)
END_EVENT_TABLE()
ExtNotebook::ExtNotebook () {}
ExtNotebook::ExtNotebook (wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style)
: wxAuiNotebook (parent, id, pos, size, style)
{
return;
}
ExtNotebook::~ExtNotebook ()
{
return;
}
void ExtNotebook::OnMouse (wxMouseEvent & event)
{
wxEventType eventType = event.GetEventType();
int x = event.GetX();
int y = event.GetY();
int tabid = HitTest(wxPoint(x, y));
if (tabid == wxNOT_FOUND) return;
if (tabid!=GetSelection()) SetSelection(tabid);
event.Skip();
}
There is a patch on sourceforge for showing a context menu on right click:
http://sourceforge.net/tracker/index.ph ... tid=309863
http://sourceforge.net/tracker/index.ph ... tid=309863
this is not a solution. First - I know nothing of patches and don't think that Visual studio supports them 2) my tabs can have different context menus and I might want to add more functionality then just that.
Why can't I catch mouse events with wxAuiNotebook ? I'd rather have a patch to fix that problem.
Why can't I catch mouse events with wxAuiNotebook ? I'd rather have a patch to fix that problem.
A patch just contains a set of changes that gets applied to your (or in this case wxWidgets) sources. After that you just recompile. There are plenty of free tools that can apply patches. It is really quite easy.
The patch in question does seem to send an event before showing the context menu. So you do get a chance to change the menu depending on the tab or doing something else instead.
The patch in question does seem to send an event before showing the context menu. So you do get a chance to change the menu depending on the tab or doing something else instead.