Tabbing out of derived wxScrolledWindow doesn't work Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Rocketmagnet
Experienced Solver
Experienced Solver
Posts: 84
Joined: Wed Aug 09, 2006 11:14 pm
Location: London
Contact:

Tabbing out of derived wxScrolledWindow doesn't work

Post by Rocketmagnet »

Hi,

I added the following code to the minimal sample:

Code: Select all

    wxSplitterWindow *splitter = new wxSplitterWindow(this, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
    splitter->SetSize(GetClientSize());
    splitter->SetSashGravity(1.0);
    wxButton* aboutBtn = new wxButton(splitter, wxID_ANY, "About");
    wxScrolledWindow* scrolledWindow = new wxScrolledWindow(splitter, -1, wxDefaultPosition, wxDefaultSize);
    splitter->SplitVertically(aboutBtn, scrolledWindow, 100);
Which produces this window:
minimal_modified.png
minimal_modified.png (4.92 KiB) Viewed 1287 times
Pressing tab repeatedly, toggles the focus between the wxButton and the wxScrolledWindow, as expected.

However, if I derive a class from wxScrolledWindow:

Code: Select all

class myScrolledWindow : public wxScrolledWindow
{
public:
    myScrolledWindow(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size)
        : wxScrolledWindow(parent, id, pos, size, wxSUNKEN_BORDER | wxVSCROLL | wxEXPAND | wxWANTS_CHARS)
    {
    }
};

// Inside MyFrame::MyFrame
    wxSplitterWindow *splitter = new wxSplitterWindow(this, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
    splitter->SetSize(GetClientSize());
    splitter->SetSashGravity(1.0);
    wxButton* aboutBtn = new wxButton(splitter, wxID_ANY, "About");
    myScrolledWindow* scrolledWindow = new myScrolledWindow(splitter, -1, wxDefaultPosition, wxDefaultSize);
    splitter->SplitVertically(aboutBtn, scrolledWindow, 100);
Now, pressing tab once moves the focus away from the wxButton, (and presumably to the myScrolledWindow), but pressing it again doesn't return it to the wxButton.

What am I missing in my class declaration that has broken the tab traversal?

Thanks
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Tabbing out of derived wxScrolledWindow doesn't work

Post by doublemax »

Without having tested it, the most obvious difference is the wxWANTS_CHARS flag that you're using for the derived class. Just deriving from wxScrolledWindow should not make any difference at all.
Use the source, Luke!
Rocketmagnet
Experienced Solver
Experienced Solver
Posts: 84
Joined: Wed Aug 09, 2006 11:14 pm
Location: London
Contact:

Re: Tabbing out of derived wxScrolledWindow doesn't work

Post by Rocketmagnet »

You genius! Thanks.
Post Reply