Skip to content

How do you get a click event from a sub-component #62

Answered by willmcgugan
sirfuzzalot asked this question in Q&A
Discussion options

You must be logged in to vote

Sorry there is no docs yet, but you have got the basic idea.

It's not enough to add a widget to the output of a render method, it needs to be "mounted". A View class will do this for you, so your TodoList should extend from View. You can then dock your CheckboxItem in the TodoList.on_mount

From there you can can create a custom message (see messages.py for example) which you can emit from CheckboxItem and handle in TodoList.

Alternatively, your CheckboxItem need not be a Widget. It could be a renderable and you can attach an action to the label via Style.on. I got this one working, here's your sample with modifications:

from typing import List, Tuple

import rich
import rich.repr
from rich.

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@sirfuzzalot
Comment options

Answer selected by sirfuzzalot
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