wxGTK has a bug for wxFrame and wxKeyEvent

4 views
Skip to first unread message

néant olivier

unread,
Feb 25, 2004, 8:46:15 AM2/25/04
to wx-te...@lists.wxwindows.org, wx-...@lists.wxwindows.org, wx-di...@lists.wxwindows.org
this code works well on Microsoft Windows but not on
Linux (Mandrake 9.1) with wxGTK 2.4.2 (not sure of my
version).

The code is :

// For compilers that support precompilation, includes
"wx/wx.h".
#include "wx/wxprec.h"

#ifdef __BORLANDC__
#pragma hdrstop
#endif

// for all others, include the necessary headers (this
file is usually all you
// need because it includes almost all "standard"
wxWindows headers)
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif

// the application icon (under Windows and OS/2 it is
in resources)
#if defined(__WXGTK__) || defined(__WXMOTIF__) ||
defined(__WXMAC__) || defined(__WXMGL__) ||
defined(__WXX11__)
#include "mondrian.xpm"
#endif

// Define a new application type, each program should
derive a class from wxApp
class MyApp : public wxApp
{
public:
virtual bool OnInit();
};

// Define a new frame type: this is going to be our
main frame
class MyFrame : public wxFrame
{
public:
// ctor(s)
MyFrame(const wxString& title, const wxPoint& pos,
const wxSize& size,
long style = wxDEFAULT_FRAME_STYLE);
void OnKeyPressed(wxKeyEvent& event);

private:
// any class wishing to process wxWindows events
must use this macro
DECLARE_EVENT_TABLE()
};

BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_KEY_DOWN(MyFrame::OnKeyPressed)
END_EVENT_TABLE()

IMPLEMENT_APP(MyApp)

bool MyApp::OnInit()
{
// create the main application window
MyFrame *frame = new MyFrame(_T("Minimal wxWindows
App"),
wxPoint(50, 50),
wxSize(450, 340));
frame->Show(TRUE);
return TRUE;
}

MyFrame::MyFrame(const wxString& title, const wxPoint&
pos, const wxSize& size, long style)
: wxFrame(NULL, -1, title, pos, size, style)
{
}


// event handlers

void MyFrame::OnKeyPressed(wxKeyEvent& event)
{
if (event.GetKeyCode()=='A') wxLogMessage(_T("Key
A Pressed"));
else wxLogMessage(_T("Not A Pressed"));
event.Skip(); // to let transmit the event
}




Yahoo! Mail : votre e-mail personnel et gratuit qui vous suit partout !
Créez votre Yahoo! Mail sur http://fr.benefits.yahoo.com/

Dialoguez en direct avec vos amis grâce à Yahoo! Messenger !Téléchargez Yahoo! Messenger sur http://fr.messenger.yahoo.com

Reply all
Reply to author
Forward
0 new messages