Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autocomplete Feature Not Working for Cyrillic Characters #108

Open
Amgarak opened this issue Oct 8, 2024 · 0 comments
Open

Autocomplete Feature Not Working for Cyrillic Characters #108

Amgarak opened this issue Oct 8, 2024 · 0 comments

Comments

@Amgarak
Copy link

Amgarak commented Oct 8, 2024

Description:

In the AutocompleteCombobox class, the handle_keyrelease method currently checks for the length of event.keysym to determine if autocomplete should be triggered. This check fails for Cyrillic characters, as their keysym has a length of 2, resulting in the autocomplete feature not functioning for these characters.

Current Implementation:

def handle_keyrelease(self, event):
    if len(event.keysym) == 1:
        self.autocomplete()

Example:

  • For the Cyrillic character "г", len(event.keysym) = 2
  • For the Latin character "g", len(event.keysym) = 1

Proposed Solution:

Update the handle_keyrelease method to allow for the autocomplete feature to be triggered for all character inputs, not just those with a keysym length of 1. The following implementation has been suggested:

import tkinter as tk
from ttkwidgets.autocomplete import AutocompleteCombobox 

class CustomAutocompleteCombobox(AutocompleteCombobox):
    def handle_keyrelease(self, event):
        if event.keysym == "BackSpace":
            self.delete(self.index(tk.INSERT), tk.END)
            self.position = self.index(tk.END)
        
        elif event.keysym == "Left":
            if self.position < self.index(tk.END):  
                self.delete(self.position, tk.END)
            else:
                self.position -= 1  
                self.delete(self.position, tk.END)
            
        elif event.keysym == "Right":
            self.position = self.index(tk.END)  
    
        elif event.keysym == "Return":
            self.handle_return(event)  
            return
        else:
            # Call autocomplete for all other keys
            self.autocomplete()

Expected Outcome:

With this change, the autocomplete feature should work correctly for both Cyrillic and Latin characters, providing a more user-friendly experience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant