Documentation error in Button::selectable()

Open Beginner friendly
#7,777 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
68/100
Issue type
Documentation
Clarity
Clearly specified
Activity status
Stale
Tech stack
rust
Domain
documentation

Research direction

Start with the Button::selectable() documentation at the linked docs.rs method and compare its equivalent code with the source implementation shown in the issue. Update the documented expression so it matches the implementation, then verify that the generated API documentation shows the corrected example.

Written by the indexing model from the issue text.

Description

bug

This is a simple error in the documentation for Button::selectable().

The documentation states that the code is equivalent to:

let selected = true;
ui.add(Button::new("toggle me").selected(selected).frame_when_inactive(!selected).frame(true));

However, the source code itself refutes this:

pub fn selectable(selected: bool, atoms: impl IntoAtoms<'a>) -> Self {
    Self::new(atoms)
        .selected(selected)
        .frame_when_inactive(selected) // <- not negated!
        .frame(true)
}

It's a super minor thing, but it just really surprised me when I first tried writing out the equivalent code in full, and the selectable buttons looked unexpectedly wrong.

Dominant language
Rust
Stars
30.6k
Forks
2.1k
Avg merge
1d 9h
Merged PRs (30d)
73

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from emilk/egui

All issues in emilk/egui

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.