2016-11-06 2 views
1

Ich habe einen einfachen wxFrame mit 3 Tasten. Nachdem ich Tab gedrückt habe passiert nichts. Im Forum habe ich festgestellt, dass wxFrame Tab-Button-Events normal verarbeiten und den Fokus zwischen den Controls setzen sollte. Ich habe es mit wxTAB_TRAVERSAL versucht und ohne es, aber sehe wie kein Ergebnis aus.wxFrame verarbeitet keine Tab-Taste

Hier ist mein Code. wxWidgets 3.0.2. Bitte, helfen Sie.

class TabWnd 
    : public wxFrame 
{ 
public: 
    TabWnd() 
     : wxFrame(nullptr, 
        wxID_ANY, 
        wxEmptyString, 
        wxDefaultPosition, 
        wxDefaultSize, 
        wxDEFAULT_FRAME_STYLE | wxTAB_TRAVERSAL) 
    { 
     wxBoxSizer* sz = new wxBoxSizer(wxVERTICAL); 

     wxButton* b1 = new wxButton(this, wxID_ANY, wxT("First")); 
     sz->Add(b1, 0, wxALL, 5); 

     wxButton* b2 = new wxButton(this, wxID_ANY, wxT("Second")); 
     sz->Add(b2, 0, wxALL, 5); 

     wxButton* b3 = new wxButton(this, wxID_ANY, wxT("Third")); 
     sz->Add(b3, 0, wxALL, 5); 

     SetSizer(sz); 
     Layout(); 
     Centre(wxBOTH); 
    } 
}; 

class WxguiApp 
    : public wxApp 
{ 
public: 
    bool OnInit() override 
    { 
     TabWnd* mainWnd = new TabWnd(); 
     mainWnd->Show(); 
     SetTopWindow(mainWnd); 

     return true; 
    } 
}; 

IMPLEMENT_APP(WxguiApp); 

Antwort

1

Versuchen Sie, eine Platte zwischen dem Rahmen und den Tasten wie folgt ergänzt:

wxBoxSizer* sz = new wxBoxSizer(wxVERTICAL); 

wxPanel* pnl = new wxPanel(this, wxID_ANY); 
wxBoxSizer* sz2 = new wxBoxSizer(wxVERTICAL); 

wxButton* b1 = new wxButton(pnl, wxID_ANY, wxT("First")); 
sz2->Add(b1, 0, wxALL, 5); 

wxButton* b2 = new wxButton(pnl, wxID_ANY, wxT("Second")); 
sz2->Add(b2, 0, wxALL, 5); 

wxButton* b3 = new wxButton(pnl, wxID_ANY, wxT("Third")); 
sz2->Add(b3, 0, wxALL, 5); 

pnl->SetSizer(sz2); 
sz->Add(pnl, 1, wxEXPAND); 

SetSizer(sz); 
Layout(); 
Centre(wxBOTH); 
Verwandte Themen