wxAuiNotebook right click?

This forum can be used to talk about general design strategies, new ideas and questions in general related to wxWidgets. If you feel your questions doesn't fit anywhere, put it here.
Post Reply
ghostdev85
Earned a small fee
Earned a small fee
Posts: 13
Joined: Mon Jun 26, 2006 9:21 am

wxAuiNotebook right click?

Post by ghostdev85 »

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
User avatar
tierra
Site Admin
Site Admin
Posts: 1355
Joined: Sun Aug 29, 2004 7:14 pm
Location: Salt Lake City, Utah, USA
Contact:

Post by tierra »

It might help if you said what platform you are on, what version of wxWidgets you are using, what you've tried to do to fix it, and last but not least, what does your code look like for setting up your event handler.
ghostdev85
Earned a small fee
Earned a small fee
Posts: 13
Joined: Mon Jun 26, 2006 9:21 am

Post by ghostdev85 »

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()
VonGodric
Earned some good credits
Earned some good credits
Posts: 103
Joined: Sun Jan 30, 2005 9:31 pm
Contact:

Post by VonGodric »

same problem here...

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();
}
Anyone?
artost
Earned a small fee
Earned a small fee
Posts: 10
Joined: Fri Feb 24, 2006 5:01 pm

Post by artost »

There is a patch on sourceforge for showing a context menu on right click:
http://sourceforge.net/tracker/index.ph ... tid=309863
VonGodric
Earned some good credits
Earned some good credits
Posts: 103
Joined: Sun Jan 30, 2005 9:31 pm
Contact:

Post by VonGodric »

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.
artost
Earned a small fee
Earned a small fee
Posts: 10
Joined: Fri Feb 24, 2006 5:01 pm

Post by artost »

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.
Post Reply