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

Add on_press_with method for Button #2502

Merged
merged 1 commit into from
Jul 12, 2024
Merged

Add on_press_with method for Button #2502

merged 1 commit into from
Jul 12, 2024

Conversation

hecrj
Copy link
Member

@hecrj hecrj commented Jul 12, 2024

This allows using a closure to produce the message only when the Button is actually pressed. Useful when generating the message may be expensive.

@hecrj hecrj added feature New feature or request widget addition labels Jul 12, 2024
@hecrj hecrj added this to the 0.13 milestone Jul 12, 2024
This allows using a closure to produce the message
only when the `Button` is actually pressed. Useful
when generating the message may be expensive.
@hecrj hecrj force-pushed the button-on-press-with branch from 3a772e7 to 97e35f7 Compare July 12, 2024 10:10
@hecrj hecrj enabled auto-merge July 12, 2024 10:12
@hecrj hecrj merged commit 65ea5fa into master Jul 12, 2024
24 checks passed
@hecrj hecrj deleted the button-on-press-with branch July 12, 2024 10:21
@nrjais
Copy link
Contributor

nrjais commented Jul 12, 2024

I think this can help with relaxing the clone requirement on the Message, If the current on_press take a message that is cloneable and uses closure to clone it on demand.

@hecrj
Copy link
Member Author

hecrj commented Jul 12, 2024

I don't see the point in adding an unnecessary heap allocation. Messages should be cloneable and other widgets demand that bound as well, like TextInput.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addition feature New feature or request widget
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants