This panel is in a wxScrollWindow.
The problem is when the wxPanel is re-drawn, while the scrollbar of the wxScrollBarWindow is on top of it, the wxPanel will be drawn over the scrollbar.
This seems to happen only on MacOS.
My environment:
- MacOS X 10.12 Sierra
- wxcocoa (wxWidgets-3.1.1)
I have reproduced this behavior in "scroll" sample code.
I added a wxPanel inside the MyCanvas.
Created a wxPanel button:
Code: Select all
class MyButton : public wxWindow
{
public:
MyButton(wxWindow *parent)
: wxWindow(parent, wxID_ANY, wxDefaultPosition, wxSize(100, 50))
{
Connect(wxEVT_PAINT, wxPaintEventHandler(MyButton::OnPaint));
Bind(wxEVT_ENTER_WINDOW, &MyButton::mouseEntered, this);
Bind(wxEVT_LEAVE_WINDOW, &MyButton::mouseLeave, this);
}
private:
void OnPaint(wxPaintEvent& WXUNUSED(event))
{
render();
}
void mouseEntered(wxMouseEvent& WXUNUSED(evt))
{
render(*wxYELLOW);
}
void mouseLeave(wxMouseEvent& WXUNUSED(evt))
{
render();
}
void render(wxColor color = *wxRED)
{
wxClientDC dc(this);
dc.SetBackground(wxBrush(color));
dc.Clear();
}
};
Code: Select all
// you can use either a single SetScrollbars() call or these 2 functions,
// usually using them is better because you normally won't need to change
// the scroll rate in the future and the sizer can be used to update the
// virtual size automatically
SetScrollRate( 10, 10 );
SetVirtualSize( 500, 1000 );
(void) new wxButton( this, ID_ADDBUTTON, "add button", wxPoint(10,10) );
(void) new wxButton( this, ID_DELBUTTON, "del button", wxPoint(10,40) );
(void) new wxButton( this, ID_MOVEBUTTON, "move button", wxPoint(150,10) );
(void) new wxButton( this, ID_SCROLLWIN, "scroll win", wxPoint(250,10) );
MyButton *btn = new MyButton(this);
wxPanel *test = new wxPanel( this, wxID_ANY,
wxPoint(10, 110), wxSize(130,50),
wxSIMPLE_BORDER | wxTAB_TRAVERSAL );
test->SetBackgroundColour( "WHEAT" );
Scrollbar is over the panel: ..when mouse is hovered, the panel is redrawn over the scrollbar:
Thanks for the help!