Skip to content

Conversation

@usbalbin
Copy link

@usbalbin usbalbin commented Nov 17, 2025

Describe the bug

Button::is_pointer_button_down_on() starts returning false after a while when still holding down the mouse button when the gui is refreshed(for example by the blinking cursor shown in the image)

To Reproduce
Steps to reproduce the behavior:

  1. In the example modified in the PR
  2. Click into the "Name" field so the cursor blinks
  3. Hold down on the button, this now shows "Hello '{}', age {}"
  4. Wait a second while keeping the button pressed
  5. Boom - egui thinks the button is released while it is not

Expected behavior

I would have expected the button to not be released

Screenshots

egui-bug

The mouse is held over the button with the left mouse button kept down. I release the mouse which can be seen when the light border appears on the button

Desktop (please complete the following information):

  • OS: 6.16.8-1-MANJARO with KDE X11

Additional context
Same thing on the clickable label works fine, no issue.

@github-actions
Copy link

Preview is being built...

Preview will be available at https://egui-pr-preview.github.io/pr/7727-show-issue

View snapshot changes at kitdiff

@usbalbin
Copy link
Author

Same problem on Win11

@lucasmerlin
Copy link
Collaborator

The culprit is long press detection.

You can add Sense::click_or_drag to work around this:

            let response = ui.add(Button::new("Increment").sense(Sense::click_and_drag()));

            if response.is_pointer_button_down_on() {
                self.age += 1;
                ui.label(format!("Hello '{}', age {}", self.name, self.age));
            }

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