AutoComplete does not work

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
giulio_seb
Earned some good credits
Earned some good credits
Posts: 108
Joined: Mon Feb 07, 2022 11:53 am

AutoComplete does not work

Post by giulio_seb »

Hello,
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!!!
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: AutoComplete does not work

Post by doublemax »

From the docs for wxTextEntry::AutoComplete
Returns true if the auto-completion was enabled or false if the operation failed, typically because auto-completion is not supported by the current platform
Did you check the return value of the call?
Use the source, Luke!
giulio_seb
Earned some good credits
Earned some good credits
Posts: 108
Joined: Mon Feb 07, 2022 11:53 am

Re: AutoComplete does not work

Post by giulio_seb »

doublemax wrote: Wed Aug 31, 2022 5:01 pm From the docs for wxTextEntry::AutoComplete
Returns true if the auto-completion was enabled or false if the operation failed, typically because auto-completion is not supported by the current platform
Did you check the return value of the call?
Thank you, I just did, it returns 1.
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: AutoComplete does not work

Post by doublemax »

giulio_seb wrote: Wed Aug 31, 2022 5:15 pm
doublemax wrote: Wed Aug 31, 2022 5:01 pm From the docs for wxTextEntry::AutoComplete
Returns true if the auto-completion was enabled or false if the operation failed, typically because auto-completion is not supported by the current platform
Did you check the return value of the call?
Thank you, I just did, it returns 1.
I actually expected it to return false.

I tested your code under Windows and it works fine there.

Try to build and run the "widgets" sample that comes with wxWidgets. Switch to the "text" window, select "Fixed-list autocompletion" from the menu and type in the text control anything that starts with "this".
Use the source, Luke!
giulio_seb
Earned some good credits
Earned some good credits
Posts: 108
Joined: Mon Feb 07, 2022 11:53 am

Re: AutoComplete does not work

Post by giulio_seb »

doublemax wrote: Wed Aug 31, 2022 5:57 pm
giulio_seb wrote: Wed Aug 31, 2022 5:15 pm
doublemax wrote: Wed Aug 31, 2022 5:01 pm From the docs for wxTextEntry::AutoComplete
Did you check the return value of the call?
Thank you, I just did, it returns 1.
I actually expected it to return false.

I tested your code under Windows and it works fine there.

Try to build and run the "widgets" sample that comes with wxWidgets. Switch to the "text" window, select "Fixed-list autocompletion" from the menu and type in the text control anything that starts with "this".
Hello, I tried it, and it doesn't work, please find the screen recording here https://streamable.com/14p26y
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: AutoComplete does not work

Post by doublemax »

giulio_seb wrote: Wed Aug 31, 2022 10:06 pm Hello, I tried it, and it doesn't work, please find the screen recording here https://streamable.com/14p26y
Was that already with a newer wxWidgets version?

If yes, please open a bug report here:
https://github.com/wxWidgets/wxWidgets/issues
Use the source, Luke!
Post Reply