On Linux, when a window is scolled, the caret incorrectly stays at the same screen location. The caret should move with the client area, as on Windows.
Incorrect behavior on Linux:
linux3.gif (view on web)
Correct behavior on Windows:
windows.gif (view on web)
To repro, run the program below on Windows and on Linux. Operate the scroll bar up and down.
Observed with wxWidgets 3.3.2, Ubuntu 24.04, Windows 11
#include <wx/wx.h>
#include <wx/caret.h>
struct ScrolledCanvas: public wxScrolled<wxWindow> {
ScrolledCanvas(wxWindow* parent)
: wxScrolled<wxWindow>(parent)
{
wxCaret* caret = new wxCaret(this, 10, 12);
caret->Show();
caret->Move(20, 24);
SetVirtualSize(120, 900);
SetScrollRate(12, 12);
SetBackgroundColour(*wxWHITE);
SetCaret(caret);
Bind(wxEVT_PAINT, &ScrolledCanvas::OnPaint, this);
}
void OnPaint(wxPaintEvent&)
{
wxPaintDC dc(this);
PrepareDC(dc);
dc.Clear();
dc.DrawText("hello\nworld", 20, 20);
}
};
struct MainFrame: public wxFrame {
MainFrame()
: wxFrame(nullptr, wxID_ANY, "Example", wxDefaultPosition, wxSize(200, 150))
{
new ScrolledCanvas(this);
}
};
struct MyApp: public wxApp {
bool OnInit() override
{
auto* frame = new MainFrame();
frame->Show();
return true;
}
};
wxIMPLEMENT_APP(MyApp);
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()