Skip to content

Autocomplete Feature Not Working for Cyrillic Characters #108

Description

@Amgarak

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions