Is it possible to show autocomplete dropdown manually

Are you writing your own components and need help with how to set them up or have questions about the components you are deriving from ? Ask them here.
Post Reply
icryrainix
Earned a small fee
Earned a small fee
Posts: 13
Joined: Mon May 20, 2019 1:31 am

Is it possible to show autocomplete dropdown manually

Post by icryrainix »

I am trying to write a custom autocomplete combobox, for example, if I input English character "a", auto completions may be other Chinese characters without "a", I can get completion arrays, but because without "a", the auto complete dropdown doesn't show.

Then, how can I make the auto complete dropdown show manually? Or how can I write this component for this purpose.

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

Re: Is it possible to show autocomplete dropdown manually

Post by doublemax »

I am trying to write a custom autocomplete combobox
Why? What are you missing from wxWidgets's built-in autocomplete functionality?

https://docs.wxwidgets.org/trunk/classw ... entry.html
Check the different wxTextEntry::AutoComplete(...) methods
Use the source, Luke!
icryrainix
Earned a small fee
Earned a small fee
Posts: 13
Joined: Mon May 20, 2019 1:31 am

Re: Is it possible to show autocomplete dropdown manually

Post by icryrainix »

I am using built in autocomplete component, but it doesn't meet my function.

I need to display different choice that without any inputs. for example, if I input "a" in combobox, but I need to show the dropdown of Chinese characters without "a". I can get auto completions including Chinese characters by custom wxtextcomplete, but the dropdown doesn't show automatically.
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Is it possible to show autocomplete dropdown manually

Post by doublemax »

I can get auto completions including Chinese characters by custom wxtextcomplete, but the dropdown doesn't show automatically.
If it doesn't show automatically (which an autocomplete usually does), when exactly does it show?

What platform are you testing on?
Use the source, Luke!
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Is it possible to show autocomplete dropdown manually

Post by ONEEYEMAN »

Hi,
Also, what locale{s} is being installed on that system? Can you successfully type Chinese words inside a regular text editor?

Thank you.
icryrainix
Earned a small fee
Earned a small fee
Posts: 13
Joined: Mon May 20, 2019 1:31 am

Re: Is it possible to show autocomplete dropdown manually

Post by icryrainix »

doublemax wrote: Fri Jun 14, 2019 4:58 am
I can get auto completions including Chinese characters by custom wxtextcomplete, but the dropdown doesn't show automatically.
If it doesn't show automatically (which an autocomplete usually does), when exactly does it show?

What platform are you testing on?
for example, if I input "z", the autocompletions are "张三" and "张四", the autocomplete dropdown will not show. But if I and "z" before autocompletions, the dropdown will show,only those autocompletions with the letter I inputted will show.

I am using windows 10 and wxwidgets 3.1.2 .
icryrainix
Earned a small fee
Earned a small fee
Posts: 13
Joined: Mon May 20, 2019 1:31 am

Re: Is it possible to show autocomplete dropdown manually

Post by icryrainix »

ONEEYEMAN wrote: Fri Jun 14, 2019 3:18 pm Hi,
Also, what locale{s} is being installed on that system? Can you successfully type Chinese words inside a regular text editor?

Thank you.
I am using the locales of Chinese(Simplified, China), I can type Chinese words inside a text editor or combobox. and if I input Chinese, the autocomplete function is OK.
icryrainix
Earned a small fee
Earned a small fee
Posts: 13
Joined: Mon May 20, 2019 1:31 am

Re: Is it possible to show autocomplete dropdown manually

Post by icryrainix »

this is the code I used to test autocomplete function with Chinese.

Code: Select all

class MyTextCompleterSimple : public wxTextCompleterSimple
{
public:
	virtual void GetCompletions(const wxString& prefix, wxArrayString& res) wxOVERRIDE
	{
		if (prefix.Contains("z"))
		{
			res.push_back("张三");
			res.push_back("z张四");
			res.push_back("张z五");
			res.push_back("zx张六");
		}
	}
};
But the result is:
autocomplete_test.png
autocomplete_test.png (15.46 KiB) Viewed 16799 times
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Is it possible to show autocomplete dropdown manually

Post by ONEEYEMAN »

Hi,
I presume you want to get rid of the "z" in the auto-complete list, right?

Thank you.
icryrainix
Earned a small fee
Earned a small fee
Posts: 13
Joined: Mon May 20, 2019 1:31 am

Re: Is it possible to show autocomplete dropdown manually

Post by icryrainix »

ONEEYEMAN wrote: Mon Jun 17, 2019 2:27 pm Hi,
I presume you want to get rid of the "z" in the auto-complete list, right?

Thank you.
I want to show all whether include "z" or not.
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4193
Joined: Sun Jan 03, 2010 5:45 pm

Re: Is it possible to show autocomplete dropdown manually

Post by PB »

The documentation for wxTextCompleterSimple::GetCompletions() states
Please notice that the returned values should start with the prefix, otherwise they will be simply ignored, making adding them to the array in the first place useless.
I think this makes it quite clear that your solution cannot work.

I also tried wxTextCompleter and the same applies.

All this makes sense considering how autocompletion is supposed to work. I think that at least on MSW, this is also a limitation of the native behaviour (however, it seems that on Vista+ a native control can use ACO_NOPREFIXFILTERING option of IAutoComplete2 to work around it).

Regarding the solution of your issue, I would start with looking into wxStyledTextCtrl autocompletion, i.e., whether the autocompletion of this control is similarly restrictive as that of wxTextCtrl. I have no experience with wxSTC so I have no idea if it is the case. Using wxSTC may also not be appropriate for your use case, as this control has entirely different purpose than a simple single line input.

Rolling one's own proper autocompletion may not be that simple but you may end up just doing that.

As the last desperate option and only if your application is MSW only, I would try changing wxWidgets source, adding ACO_NOPREFIXFILTERING option in the wxTextAutoCompleteData ctor.
New Pagodi
Super wx Problem Solver
Super wx Problem Solver
Posts: 466
Joined: Tue Jun 20, 2006 6:47 pm
Contact:

Re: Is it possible to show autocomplete dropdown manually

Post by New Pagodi »

Are you maybe asking about IME instead of autocompletion?
icryrainix
Earned a small fee
Earned a small fee
Posts: 13
Joined: Mon May 20, 2019 1:31 am

Re: Is it possible to show autocomplete dropdown manually

Post by icryrainix »

PB wrote: Tue Jun 18, 2019 7:18 am The documentation for wxTextCompleterSimple::GetCompletions() states
Please notice that the returned values should start with the prefix, otherwise they will be simply ignored, making adding them to the array in the first place useless.
I think this makes it quite clear that your solution cannot work.

I also tried wxTextCompleter and the same applies.

All this makes sense considering how autocompletion is supposed to work. I think that at least on MSW, this is also a limitation of the native behaviour (however, it seems that on Vista+ a native control can use ACO_NOPREFIXFILTERING option of IAutoComplete2 to work around it).

Regarding the solution of your issue, I would start with looking into wxStyledTextCtrl autocompletion, i.e., whether the autocompletion of this control is similarly restrictive as that of wxTextCtrl. I have no experience with wxSTC so I have no idea if it is the case. Using wxSTC may also not be appropriate for your use case, as this control has entirely different purpose than a simple single line input.

Rolling one's own proper autocompletion may not be that simple but you may end up just doing that.

As the last desperate option and only if your application is MSW only, I would try changing wxWidgets source, adding ACO_NOPREFIXFILTERING option in the wxTextAutoCompleteData ctor.
Thank you very much for you detailed instruction, I will try wxStyledTextCtrl, or changing source code.
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4193
Joined: Sun Jan 03, 2010 5:45 pm

Re: Is it possible to show autocomplete dropdown manually

Post by PB »

In case you missed New Pagodi's post, make sure autocompletion is really what you want and you are not confusing it with IME:
https://en.wikipedia.org/wiki/Input_method
ollydbg23
Super wx Problem Solver
Super wx Problem Solver
Posts: 438
Joined: Fri Dec 12, 2008 10:31 am

Re: Is it possible to show autocomplete dropdown manually

Post by ollydbg23 »

I think the OP want the feature like in this link: Visual Assist Features: Coding Assistance - Whole Tomato Software.

When user enter: "lstb", the autocompletion shows an entry "LuaStackToBinary".
Post Reply