Can not use tab-key on MAC OSX.

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
killrain
In need of some credit
In need of some credit
Posts: 6
Joined: Mon Apr 05, 2010 1:52 pm

Can not use tab-key on MAC OSX.

Post by killrain »

hi~
i have a problem with the tab key on MAC OSX.

there are some text controls on the panel.
and main window has that panel. like below

CMainWnd (1)
+- wxPanel (2)
__+- wxTextCtrl (3)
__+- wxTextCtrl (4)


when i press tab-key at first textctrl, focus does not go to second textctrl on MAC OSX. but it works well on ms windows!

controls are created with that code below.

Code: Select all

// main window creation
m_pMainWnd->Create( ..., wxDEFAULT_FRAME_STYLE | wxTAB_TRAVERSAL | wxFULL_REPAINT_ON_RESIZE )

// panel creation
pLoginPanel->Create( ..., wxBORDER_NONE | wxTAB_TRAVERSAL | wxFULL_REPAINT_ON_RESIZE | wxCLIP_CHILDREN )

// text cotrols creation
m_ptxtId->Create( ..., wxTE_PROCESS_ENTER | wxNO_BORDER )
m_ptxtPwd->Create( ..., wxTE_PROCESS_ENTER | wxTE_PASSWORD | wxNO_BORDER )
Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria »

This works for me :

Code: Select all

#include "wx/wx.h"

class MyFrame : public wxFrame
{
public:
    MyFrame() : wxFrame(NULL, wxID_ANY,  wxT("Hello wxWidgets"), wxPoint(50,50), wxSize(800,600))
    {
        wxPanel* mainPane = new wxPanel(this);
        wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
        
        wxTextCtrl* a = new wxTextCtrl(mainPane, wxID_ANY, wxT("a"), wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
        wxTextCtrl* b = new wxTextCtrl(mainPane, wxID_ANY, wxT("b"), wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
        wxTextCtrl* c = new wxTextCtrl(mainPane, wxID_ANY, wxT("c"), wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);

        sizer->Add(a, 0, wxALL, 5);
        sizer->Add(b, 0, wxALL, 5);
        sizer->Add(c, 0, wxALL, 5);
        mainPane->SetSizer(sizer);
    }
};

class MyApp: public wxApp
{
    wxFrame* m_frame;
public:
    
    bool OnInit()
    {
        m_frame = new MyFrame();
        m_frame->Show();
        return true;
    } 
    
};

IMPLEMENT_APP(MyApp)
I suspect you need to give the tab traversal flag to each text control, but I'm not 100% sure what is the difference between your code and mine
"Keyboard not detected. Press F1 to continue"
-- Windows
moki
Earned a small fee
Earned a small fee
Posts: 14
Joined: Mon Dec 08, 2014 1:08 pm
Location: Brive la gaillarde

Re: Can not use tab-key on MAC OSX.

Post by moki »

The difference between yours codes may be the wxTE_PASSWORD flag.

I am probably encountering the same bug (wx 3.1.0), and if I remove this flag, my code works as expected. But i's not a very usable solution... :?

The wx 3.1.1 version fixes many tab issues, but I am not using yet.
Post Reply