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

Refactor radio button to use value container #292

Merged
merged 2 commits into from
Jan 25, 2024

Conversation

pieterdd
Copy link
Contributor

No description provided.

{
radio_button_svg(represented_value, actual_value).keyboard_navigatable()
let (inbound_signal, outbound_signal) = create_value_container_signals(actual_value);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should make the T in create_value_container_signals Clone rather than Copy.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. I kept the Copy of the T in the radio button functions though, since I have to move a copy of represented_value into a closure there.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can create a clone for it as well. Copy is just so strict here.

e.g.

let local_represented_value = represented_value.clone();
value_container(
        radio_button_svg(represented_value, inbound_signal.read_only())
            .keyboard_navigatable()
            .on_click_stop(move |_| {
                outbound_signal.set(local_represented_value.clone());
            }),
        move || outbound_signal.get(),
    )

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I didn't realize Rust treated a let differently than a function parameter. Thanks for the tip, I think I fixed it.

@pieterdd pieterdd force-pushed the port-radio-button branch 2 times, most recently from 3b48b44 to ac41434 Compare January 25, 2024 19:50
@dzhou121 dzhou121 merged commit 48ba307 into lapce:main Jan 25, 2024
7 checks passed
jrmoulton pushed a commit to jrmoulton/floem that referenced this pull request Feb 2, 2024
* Replace Copy with Clone

* Refactor radio button to use value container
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 this pull request may close these issues.

2 participants