Skip to content

on_click event in ft.Container not works (on_hover works fine) #4061

Closed Answered by InesaFitsner
LukasSliacky asked this question in Q&A
Discussion options

You must be logged in to vote

on_click doesn't work for those two containers because the content of each container is IconButton and when you click on it, it would trigger on_click event for IconButton, not Container.

You can specify on_click for the IconButton:


      content=ft.IconButton(
          icon=icon,
          icon_size=22,
          style=ft.ButtonStyle(
              color={"": "white"}),
          on_click=lambda e: print('on_click_event'),
    
      )

If you want to make sure that on_click event works for Container, try it for the _main_container:

    _main_container = ft.Container(
        width=280,
        height=590,
        bgcolor="black",
        alignment=ft.alignment.bottom_center,
        b…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by LukasSliacky
Comment options

You must be logged in to vote
2 replies
@LukasSliacky
Comment options

@tanmay-bhatgare
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #4059 on September 27, 2024 21:10.