[Kivy] / TextInput Üzerinde Ekran Klavyenin Çıkmaması

(17.11.2025 tarihinde oluşturuldu.)

Öncelikle TextInput sınıfından miras alarak kendi sınıfımızı oluşturuyoruz;

class TextInputFixed(TextInput):
    def on_focus(self, instance, value, *args):
        if value:
            Clock.schedule_once(self.create_keyboard, .1)
        else:
            self.hide_keyboard()

    def create_keyboard(self, *args):
        self.show_keyboard()

    def remove_focus_decorator(function):
        def wrapper(self, touch):
            if not self.collide_point(*touch.pos):
                self.focus = False
            function(self, touch)
        return wrapper

    @remove_focus_decorator
    def on_touch_down(self, touch):
        super().on_touch_down(touch)


Ardından KV dilinde kendi özelleştirdiğimiz TextInputFixed içindeki keyboard_mode parametresini 'managed' olarak ayarlıyoruz.

<ScreenOne>:
    BoxLayout:
        orientation: 'vertical'
        TextInputFixed:
            pos_hint: {'center_x': .5}
            keyboard_mode: 'managed'
            on_text_validate: tf.focus = True
        Label:
            text: 'Password:'
            size_hint_y: None
            height: self.texture_size[1]
        TextInputFixed:
            id: tf
            pos_hint: {'center_x': .5}
            keyboard_mode: 'managed'
        Widget:


Yukarıdaki örnek kod neticesinde söz konusu problemin giderildiğini tecrübe ettim.


Kaynak: https://github.com/kivy/kivy/issues/7698


YORUMLAR (0 yorum)



Yorum Gönder
CAPTCHA