How to distinguish between mouse click and touchpad tap events in Tkinter?

Viewed 64

I have an application running on a Windows PC having both touchscreen and mouse.

On this application there are some Entry widgets and I would need a virtual keyboard appearing when tapping on them, but not when they get clicked using the mouse.

This is what my code looks like at the moment:

class TouchEntry(ttk.Entry):
    def __init__(self, parent, *args, **kwargs):
        ttk.Entry.__init__(self, parent, *args, **kwargs)
        self.bind("<Button-1>", self._call_osk)

    def _call_osk(self, event):
        open_virtual_keyboard()
        self.focus_force()

Of course this doesn't do what I desire since the "Button" event does not distinguish between click and tap.

As far as I know there isn't a "Tap" event in Tkinter, but I was wondering if there's another possible approach to solve the problem.

0 Answers
Related