flet-dev / flet

Flet enables developers to easily build realtime web, mobile and desktop apps in Python. No frontend experience required.
https://flet.dev
Apache License 2.0
9.59k stars 372 forks source link

Container "long press action" triggered both ```on_click``` and ```on_long_press``` events #2712

Closed lekshmanmj closed 1 month ago

lekshmanmj commented 3 months ago

Description Container long press triggered both on_click and on_long_press events when I test this events in flet android test app. command: flet run --android

Code example to reproduce the issue:

import flet as ft

def main(page: ft.Page):
    page.padding = 0
    def on_long_press(e):
        print('on long press')
        page.add(ft.Text('on_long_press triggered'))
    def on_click(e):
        print('on click')
        page.add(ft.Text('on_click triggered'))
    container = ft.Container(
        bgcolor= ft.colors.RED,
        content= ft.Text('Test Long Press'),
        height= 100,
        width= 100,
        on_click= on_click,
        on_long_press= on_long_press 
    )
    page.add(ft.SafeArea(container))

ft.app(target=main)

Describe the results you received: Screenshot_2024-02-22-04-20-44-856_com appveyor flet

Describe the results you expected: Expected it to trigger only long_press event on "long press" action even when both on_click and on_long_press event methods are set.

Flet version (pip show flet):

Name: flet
Version: 0.20.2
Summary: Flet for Python - easily build interactive multi-platform apps in Python
Home-page: 
Author: Appveyor Systems Inc.
Author-email: hello@flet.dev
License: Apache-2.0
Location: /home/lekshman/bbb/bbb_env/lib/python3.11/site-packages
Requires: cookiecutter, flet-runtime, packaging, qrcode, watchdog, websocket-client, websockets
Required-by: 

Give your requirements.txt file (don't pip freeze, instead give direct packages):

flet

Operating system: Kali Linux - debian based OS

Additional environment details: Test environment is Flet android testing app.

ndonkoHenri commented 1 month ago

Should have been fixed by https://github.com/flet-dev/flet/pull/2914

jmv74211 commented 2 weeks ago

Hello @ndonkoHenri

I think it has been fixed in the desktop app version, but I'm trying it on Android and I think it still doesn't work.

When trying to do the on_long_press on a container, it always triggers the on_click event first.

I have the version updated to 0.22.1.

Could you please check it?

Thanks.