mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 03:57:43 +00:00
LibGUI: Mimic a user click when calling Button::click()
The `mimic_pressed` function was primarily used in one place, the Calculator. This patch removes quite a lot of logic duplication there. It is also profitable to a lot of other places where `click()` was called without mimicking a click.
This commit is contained in:
parent
96b3063121
commit
d4ef2e226c
5 changed files with 37 additions and 54 deletions
|
@ -136,6 +136,9 @@ void Button::click(unsigned modifiers)
|
|||
return;
|
||||
set_checked(!is_checked());
|
||||
}
|
||||
|
||||
mimic_pressed();
|
||||
|
||||
if (on_click)
|
||||
on_click(modifiers);
|
||||
if (m_action)
|
||||
|
@ -248,7 +251,7 @@ void Button::set_default(bool default_button)
|
|||
|
||||
void Button::mimic_pressed()
|
||||
{
|
||||
if (!is_being_pressed()) {
|
||||
if (!is_being_pressed() && !was_being_pressed()) {
|
||||
m_mimic_pressed = true;
|
||||
|
||||
stop_timer();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue