- Dell Venue-11-Pro-7140
- Linux version 5.15.0-49-generic
- running with ubuntu jammy, 22.04 LTS
- currently installed wxWidgets version: 3.0.5.1+dfsg-4
- also pulled and built the latest wxWidgets from github, version 3.2.0, same behavior
- currently installed gtk version: 3.24.33-1ubuntu2
- gtk's example program, example-4, build against installed gtk 3.0, does not show this behavior, ie, screen touches show the proper coordinates
- a program that uses X11 directly does not show this behavior (code available if needed)
- wxWidget's example, examples/samples/drawing/drawing.cpp shows yet a different behavior. The touch scrolls the window and does not return a coordinate. A long press does return the proper coordinate. For this case, the drawing area is derived from wxScrolledWindow (vs wxPanel in my case)
Thanks for your help.
This is the code condensed to minimal that I used to test:
Code: Select all
// wxWidgets testmouse implementation
// For compilers that support precompilation, includes "wx/wx.h".
// This one is generic across platforms.
#include <wx/wxprec.h>
// Precompiled headers speeds up the header include. If not done, need this include.
#ifndef WX_PRECOMP
#include <wx/wx.h>
#endif
#include <iostream>
using namespace std;
// Most all apps need this.
// OnInit typically creates and initializes the main window.
class TestMouse : public wxApp
{
public:
virtual bool OnInit();
};
class TestMouseFrame;
class TestMouseCanvas : public wxPanel {
public:
TestMouseCanvas( TestMouseFrame* parent );
void dumpMouseData( const char* title, wxMouseEvent& event );
void OnMouseLeftDownEvent(wxMouseEvent& event);
void OnMouseLeftUpEvent(wxMouseEvent& event);
void OnMouseMotionEvent(wxMouseEvent& event);
TestMouseFrame* parent() { return _parent; }
private:
friend class TestMouseFrame;
TestMouseFrame* _parent;
wxDECLARE_EVENT_TABLE();
};
// This defines/creates the main window. OnInit creates one of these.
class TestMouseFrame : public wxFrame
{
public:
TestMouseFrame();
TestMouseCanvas* ncCanvas();
private:
friend class TestMouseCanvas;
TestMouseCanvas* _canvas;
void OnExit(wxCommandEvent& event);
// Following needed in order to handle mouse, key, or menu button actions
wxDECLARE_EVENT_TABLE();
};
wxDEFINE_EVENT( EVT_COMMAND_REFRESH, wxCommandEvent );
// Define which events are associated with which handlers.
wxBEGIN_EVENT_TABLE(TestMouseFrame, wxFrame)
EVT_MENU(wxID_EXIT, TestMouseFrame::OnExit)
wxEND_EVENT_TABLE()
// Does the "main", starts the program
wxIMPLEMENT_APP(TestMouse);
bool TestMouse::OnInit()
{
// Creates the main window
// OnInit is called upon startup.
TestMouseFrame *frame = new TestMouseFrame();
frame->Show( true );
// Above doesnt return until the program ends
return true;
}
// The TestMouseFrame constructor has all the guts of defining the main window.
TestMouseFrame::TestMouseFrame()
: wxFrame(NULL, wxID_ANY, "TestMouse", wxDefaultPosition, wxSize(400,400))
{
_canvas = new TestMouseCanvas(this);
}
TestMouseCanvas* TestMouseFrame::ncCanvas() { return _canvas; }
// Handler for when "Quit" is selected from the menus
void TestMouseFrame::OnExit(wxCommandEvent& event)
{
Close( true );
}
BEGIN_EVENT_TABLE(TestMouseCanvas, wxPanel)
EVT_LEFT_DOWN(TestMouseCanvas::OnMouseLeftDownEvent)
EVT_LEFT_UP(TestMouseCanvas::OnMouseLeftUpEvent)
EVT_MOTION(TestMouseCanvas::OnMouseMotionEvent)
END_EVENT_TABLE()
TestMouseCanvas::TestMouseCanvas(TestMouseFrame* parent) : wxPanel(parent,wxID_ANY) {
_parent = parent;
};
void TestMouseCanvas::dumpMouseData( const char* title, wxMouseEvent& event ) {
int x1 = GetScreenPosition().x;
int y1 = GetScreenPosition().y;
wxMouseState mstate = wxGetMouseState();
int x2 = mstate.GetX();
int y2 = mstate.GetY();
const wxPoint point = wxGetMousePosition();
int x3 = point.x;
int y3 = point.y;
cout << title << ' '
<< x1 << ' ' << y1 << ' '
<< x2 << ' ' << y2 << ' '
<< x3 << ' ' << y3 << ' '
<< endl;
}
void TestMouseCanvas::OnMouseMotionEvent(wxMouseEvent& event) {
// Used to move the volume level with the mouse movement.
dumpMouseData( "Mouse Move", event );
}
void TestMouseCanvas::OnMouseLeftDownEvent(wxMouseEvent& event) {
dumpMouseData( "Left Down", event );
}
void TestMouseCanvas::OnMouseLeftUpEvent(wxMouseEvent& event) {
dumpMouseData( "Left Up", event );
}