|
|
 | | From: | T. S. Ferreira | | Subject: | Bug in wxGTK-2.5.3 with mouse events? | | Date: | Sat, 22 Jan 2005 18:31:25 +0000 (UTC) |
|
|
 | ------=_Part_1443_31577204.1106418634664 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline
There seems to be a problem with detecting mouse events in version wxGTK-2.5.3. I wrote a simple program (attached) to follow the detection of the four events:
EVT_ENTER_WINDOW EVT_LEAVE_WINDOW EVT_LEFT_DOWN EVT_LEFT_UP It shows in a wxTextCtrl window the occurrence of each event, as the mouse moves between the main frame and a set of buttons, and as the left mouse button is being pressed down and released.
The program should always identify the button over which each action occurs. However in this version the button reported in release (UP) event is the same one on which the previous press (DOWN) event occurred, even if the mouse was moved between these two events.
For example, if I press the mouse left button over the button 0 and release it over the button 3, it still reports as having been released over the button 0. On the other hand, the program works correctly under wxGTK-2.4.2.
Is this a bug, or something changed? Why?
Thanks,
-- T. S. Ferreira
------=_Part_1443_31577204.1106418634664 Content-Type: text/plain; name="testmouse.cpp" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="testmouse.cpp"
// ------------------------------------------------------------------------= ---- // headers // ------------------------------------------------------------------------= ----
// For compilers that support precompilation, includes "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
#define BUTTON_SIZE 100 #define BUTTON_NUM 5 #define TEXT_WIDTH 200 #define TEXT_HEIGHT 400 #define FRAME_WIDTH (TEXT_WIDTH+BUTTON_NUM*BUTTON_SIZE) #define FRAME_HEIGHT TEXT_HEIGHT=20
#define SHOW_STATUS_ID(txt) \ textmsg.Printf(_T(txt "\n"),GetId()); \ frame->text->AppendText(textmsg);
#define SHOW_STATUS(txt) \ frame->text->AppendText(_T(txt "\n"));
// Global for formatting status messages wxString textmsg;
// ------------------------------------------------------------------------= ---- // Main application // ------------------------------------------------------------------------= ---
class MyApp : public wxApp { public: virtual bool OnInit(); };
IMPLEMENT_APP(MyApp)
class Button; class MainFrame;
MainFrame *frame;
// ------------------------------------------------------------------------= --- // Button // ------------------------------------------------------------------------= --- class Button : public wxButton { public: Button(MainFrame *parent, wxWindowID id, const wxString& label, =09 const wxPoint pos, const wxSize size); // constructor void OnEnterButton(wxMouseEvent& event); void OnLeaveButton(wxMouseEvent& event); void OnButtonDown(wxMouseEvent& event); void OnButtonUp(wxMouseEvent& event); private: DECLARE_EVENT_TABLE() };
// ------------------------------------------------------------------------= --- // MainFrame // ------------------------------------------------------------------------= --- class MainFrame : public wxFrame { public: MainFrame(); // constructor void OnEnterButton(wxMouseEvent& event); void OnLeaveButton(wxMouseEvent& event); void OnButtonDown(wxMouseEvent& event); void OnButtonUp(wxMouseEvent& event); wxTextCtrl *text; private: Button *buttons[BUTTON_NUM]; DECLARE_EVENT_TABLE() };
// // ---------------------------------------------------------------------= ------ // // Main application event // // ---------------------------------------------------------------------= ------
bool MyApp::OnInit() { frame =3D new MainFrame(); frame->Show(TRUE); return TRUE; }
BEGIN_EVENT_TABLE(Button,wxButton) EVT_ENTER_WINDOW(Button::OnEnterButton) EVT_LEAVE_WINDOW(Button::OnLeaveButton) EVT_LEFT_DOWN(Button::OnButtonDown) EVT_LEFT_UP(Button::OnButtonUp) END_EVENT_TABLE()
BEGIN_EVENT_TABLE(MainFrame,wxFrame) EVT_ENTER_WINDOW(MainFrame::OnEnterButton) EVT_LEAVE_WINDOW(MainFrame::OnLeaveButton) EVT_LEFT_DOWN(MainFrame::OnButtonDown) EVT_LEFT_UP(MainFrame::OnButtonUp) END_EVENT_TABLE()
// ------------------------------------------------------------------------= --- // Constructors // ------------------------------------------------------------------------= ---
// ------------------------------------------------------------------------= ---
Button::Button(MainFrame *parent, wxWindowID id, const wxString& label, =09 const wxPoint pos, const wxSize size) : wxButton(parent,id,label,pos,size) { }
MainFrame::MainFrame() : wxFrame((wxFrame *)NULL, -1, "Test of button events",wxDefaultPosition, =09 wxSize(FRAME_WIDTH,FRAME_HEIGHT)) { text =3D new wxTextCtrl(this,-1,"",wxPoint(0,0),wxSize(TEXT_WIDTH,TEXT_HE= IGHT), =09=09=09wxTE_READONLY | wxTE_MULTILINE); int i; wxString label; for (i=3D0; i label.Printf(_T("%d"),i); buttons[i] =3D new Button(this,i,label,wxPoint(i*BUTTON_SIZE+TEXT_WIDTH= ,BUTTON_SIZE), =09=09=09 wxSize(BUTTON_SIZE,BUTTON_SIZE)); } }
// // ---------------------------------------------------------------------= ------ // // Event handlers // // ---------------------------------------------------------------------= ------
// Button
void Button::OnEnterButton(wxMouseEvent& event) { SHOW_STATUS_ID("Mouse entered button %d"); }
void Button::OnLeaveButton(wxMouseEvent& event) { SHOW_STATUS_ID("Mouse left button %d"); }
void Button::OnButtonDown(wxMouseEvent& event) { SHOW_STATUS_ID("Mouse down on button %d"); }
void Button::OnButtonUp(wxMouseEvent& event) { SHOW_STATUS_ID("Mouse up on button %d"); }
// MainFrame
void MainFrame::OnEnterButton(wxMouseEvent& event) { SHOW_STATUS("Mouse entered frame"); }
void MainFrame::OnLeaveButton(wxMouseEvent& event) { SHOW_STATUS("Mouse left frame"); }
void MainFrame::OnButtonDown(wxMouseEvent& event) { SHOW_STATUS("Mouse down on frame"); }
void MainFrame::OnButtonUp(wxMouseEvent& event) { SHOW_STATUS("Mouse up on frame"); }
------=_Part_1443_31577204.1106418634664 Content-Type: text/plain; charset=us-ascii
--------------------------------------------------------------------- To unsubscribe, e-mail: wx-users-unsubscribe@lists.wxwidgets.org For additional commands, e-mail: wx-users-help@lists.wxwidgets.org ------=_Part_1443_31577204.1106418634664--
|
|
 | | From: | T. S. Ferreira | | Subject: | Re: Bug in wxGTK-2.5.3 with mouse events? | | Date: | Sun, 23 Jan 2005 16:24:35 +0000 (UTC) |
|
|
 | On Sun, 23 Jan 2005 11:30:32 -0200, T. S. Ferreira wrote: > On Sun, 23 Jan 2005 12:15:50 +0100, Robert Roebling wrote: > > > > > > > > [... snip ...] > > > > Sure, the mouse (input) was captured after the left mouse > > button click. That is how the native control works. I'm > > not sure why wxGTK 2.4.2 doesn't show the behaviour, though. > > Are you using the same GTK+ version? > > > > Robert > > > > > > Yes, I compiled both versions on the same Linux machine (Fedora Core > 3), so that they should use the same GTK+ (unless there was some > update of GTK+ between the two installations!). I also tested the same > program under Windows (wxMSW-2.4.2) and it works just like wxGTK-2.4.2 > which seems correct and is what I would like it to do! Like this I can > implement my own actions like dragging and selection of several > buttons. Notice that I do not detect a complete click but the events > mouse-down and mouse-up. >
I just tested it under wxMSW-2.5.3, and it works the way I expected. The only exception seems to be wxGTK-2.5.3 :-(.
-- T. S. Ferreira
--------------------------------------------------------------------- To unsubscribe, e-mail: wx-users-unsubscribe@lists.wxwidgets.org For additional commands, e-mail: wx-users-help@lists.wxwidgets.org
|
|
 | | From: | T. S. Ferreira | | Subject: | Re: Bug in wxGTK-2.5.3 with mouse events? | | Date: | Sun, 23 Jan 2005 13:31:22 +0000 (UTC) |
|
|
 | On Sun, 23 Jan 2005 12:15:50 +0100, Robert Roebling wrote: > > > > > [... snip ...] > > Sure, the mouse (input) was captured after the left mouse > button click. That is how the native control works. I'm > not sure why wxGTK 2.4.2 doesn't show the behaviour, though. > Are you using the same GTK+ version? > > Robert > >
Yes, I compiled both versions on the same Linux machine (Fedora Core 3), so that they should use the same GTK+ (unless there was some update of GTK+ between the two installations!). I also tested the same program under Windows (wxMSW-2.4.2) and it works just like wxGTK-2.4.2 which seems correct and is what I would like it to do! Like this I can implement my own actions like dragging and selection of several buttons. Notice that I do not detect a complete click but the events mouse-down and mouse-up.
-- T. S. Ferreira
--------------------------------------------------------------------- To unsubscribe, e-mail: wx-users-unsubscribe@lists.wxwidgets.org For additional commands, e-mail: wx-users-help@lists.wxwidgets.org
|
|
 | | From: | Robert Roebling | | Subject: | Re: Bug in wxGTK-2.5.3 with mouse events? | | Date: | Sun, 23 Jan 2005 11:07:40 +0000 (UTC) |
|
|
 | > There seems to be a problem with detecting mouse events in version > wxGTK-2.5.3. I wrote a simple program (attached) to follow the > detection of the four events: > > EVT_ENTER_WINDOW > EVT_LEAVE_WINDOW > EVT_LEFT_DOWN > EVT_LEFT_UP > > It shows in a wxTextCtrl window the occurrence of each event, as the > mouse moves between the main frame and a set of buttons, and as the > left mouse button is being pressed down and released. > > The program should always identify the button over which each action > occurs. However in this version the button reported in release (UP) > event is the same one on which the previous press (DOWN) event > occurred, even if the mouse was moved between these two events.
Sure, the mouse (input) was captured after the left mouse button click. That is how the native control works. I'm not sure why wxGTK 2.4.2 doesn't show the behaviour, though. Are you using the same GTK+ version?
Robert
--------------------------------------------------------------------- To unsubscribe, e-mail: wx-users-unsubscribe@lists.wxwidgets.org For additional commands, e-mail: wx-users-help@lists.wxwidgets.org
|
|
|