mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 13:28:11 +00:00
LibGUI: Add mimic_pressed
to Button to signify being virtually clicked
A button that is "mimic pressed" is drawn like it is being clicked when it isn't necessarily actually being pressed. This lets programs which keyboard based input that mirrors a button to show visual feedback when a key is pressed.
This commit is contained in:
parent
1fd16232d3
commit
e8f6a650ad
2 changed files with 11 additions and 1 deletions
|
@ -55,7 +55,7 @@ void Button::paint_event(PaintEvent& event)
|
|||
Painter painter(*this);
|
||||
painter.add_clip_rect(event.rect());
|
||||
|
||||
bool paint_pressed = is_being_pressed() || (m_menu && m_menu->is_visible());
|
||||
bool paint_pressed = is_being_pressed() || is_mimic_pressed() || (m_menu && m_menu->is_visible());
|
||||
|
||||
Gfx::StylePainter::paint_button(painter, rect(), palette(), m_button_style, paint_pressed, is_hovered(), is_checked(), is_enabled(), is_focused(), is_default() && !another_button_has_focus());
|
||||
|
||||
|
@ -222,4 +222,10 @@ void Button::set_default(bool default_button)
|
|||
});
|
||||
}
|
||||
|
||||
void Button::set_mimic_pressed(bool mimic_pressed)
|
||||
{
|
||||
m_mimic_pressed = mimic_pressed;
|
||||
update();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue