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

Slider support on_pressed and on_released event #596

Closed
moshstudio opened this issue Nov 19, 2022 · 7 comments · Fixed by #620
Closed

Slider support on_pressed and on_released event #596

moshstudio opened this issue Nov 19, 2022 · 7 comments · Fixed by #620

Comments

@moshstudio
Copy link

moshstudio commented Nov 19, 2022

I want to use Slider to implement a audio slide control component,but there's no on_pressed and on_release event, it bothers me >_<

@ndonkoHenri
Copy link
Contributor

Why not use the on_change event?
https://flet.dev/docs/controls/slider#on_change

@moshstudio
Copy link
Author

Why not use the on_change event? https://flet.dev/docs/controls/slider#on_change

Slider goes with Audio playing,but when i pressed Slider, Audio must no more push the Slider untill i release the Slider, so i need to know the Slider press and release event. (forgive my poor english)

@FeodorFitsner
Copy link
Contributor

I guess Slider.onChangeStart and Slider.onChangeEnd should work then?

@moshstudio
Copy link
Author

I guess Slider.onChangeStart and Slider.onChangeEnd should work then?

Yeah, that's exactly what i need! Could you please fix it? that'll be a big help.[smile face]

@FeodorFitsner
Copy link
Contributor

Sure, will make a PR tomorrow.

@FeodorFitsner
Copy link
Contributor

Sample code:

import flet as ft

def main(page: ft.Page):
    page.add(
        ft.Slider(
            width=200,
            on_change=lambda e: print("ON CHANGE:", e.data),
            on_change_start=lambda e: print("ON CHANGE START:", e.data),
            on_change_end=lambda e: print("ON CHANGE END:", e.data),
        ),
    )

ft.app(target=main)

@FeodorFitsner
Copy link
Contributor

The feature has been published as a pre-release and can be installed with the following command:

pip install flet --pre

Usage example:

import flet as ft

def main(page: ft.Page):
    page.add(
        ft.Slider(
            width=200,
            on_change=lambda e: print("ON CHANGE:", e.data),
            on_change_start=lambda e: print("ON CHANGE START:", e.data),
            on_change_end=lambda e: print("ON CHANGE END:", e.data),
        ),
    )

ft.app(target=main)

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

Successfully merging a pull request may close this issue.

3 participants