I am on OSX 12.2 and wxWidgets 3.1.5. In this toy code, I would like the text entered by the user in the wxTextCtrl box, to be autocompleted according to the list items:
Code: Select all
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
class MyApp : public wxApp
{
public:
virtual bool OnInit();
};
class Simple : public wxFrame
{
public:
Simple(const wxString& title);
wxPanel* panel;
wxTextCtrl* box;
wxArrayString items;
};
IMPLEMENT_APP(MyApp)
Simple::Simple(const wxString& title)
: wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(250, 150))
{
panel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, wxT(""));
items.Add(wxString("pere"));
items.Add(wxString("mele"));
box = new wxTextCtrl(panel, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize);
box->AutoComplete(items);
}
bool MyApp::OnInit()
{
Simple *simple = new Simple(wxT("Michele"));
simple->Show(true);
return true;
}
However, when I type a word which starts as one of the words in 'items', nothing happens. May you please help me with this ?
Thanks!!!