AW: 2 questions : (...) GTK toolbar mouse events
olivier.corrio at gmail.com
olivier.corrio at gmail.com
Fri Jan 12 00:28:31 PST 2007
Hi,
i m on a mandriva 2007 with gtk+2.10.3 Here is a piece of code to
reproduce (works on at leat motif didn't test it on windows)
#include <wx/wx.h>
class MyApp : public wxApp
{
public:
virtual bool OnInit();
};
class MyFrame : public wxFrame
{
public:
MyFrame(wxWindow*);
};
class MyToolBar : public wxToolBar
{
public:
MyToolBar(wxWindow* parent);
void OnClick(wxMouseEvent& event);
DECLARE_EVENT_TABLE()
};
BEGIN_EVENT_TABLE(MyToolBar,wxToolBar)
EVT_LEFT_DOWN(MyToolBar::OnClick)
END_EVENT_TABLE()
IMPLEMENT_APP(MyApp)
bool MyApp::OnInit()
{
MyFrame* frame = new MyFrame(NULL);
frame->Show(true);
return true;
}
MyFrame::MyFrame(wxWindow* parent) : wxFrame(parent,-1,wxEmptyString)
{
MyToolBar *toolbar=new MyToolBar(this);
wxBitmap *bitmap;
wxMemoryDC dc;
for(int i=1;i<5;i++) {
bitmap=new wxBitmap(20,20);
dc.SelectObject(*bitmap);
dc.Clear();
dc.DrawText(wxString::Format("%d",i),5,5);
toolbar->AddTool(-1,wxEmptyString,*bitmap);
}
SetToolBar(toolbar);
}
MyToolBar::MyToolBar(wxWindow* parent) : wxToolBar(parent,-1)
{
}
void MyToolBar::OnClick(wxMouseEvent& event)
{
wxMessageBox("Left click");
}
Thanks
"Robert Roebling" a écrit :
> > It is not possible with GTK2 to catch mouse events coming from a
> > toolbar (but with GTK1 it works)
>
> I've seen this report before but I was unable to reproduce the
> problem (I could e.g. create a popup menu for configuring
> the toolbar after a right mouse click) so it might depend
> on the GTK version or something else I don't know about.
> Which version of GTK+ and wxWidgets are you using?
>
> Robert
>
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wx-users-unsubscribe at lists.wxwidgets.org
> For additional commands, e-mail: wx-users-help at lists.wxwidgets.org
More information about the wx-users
mailing list