mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 07:55:07 +00:00
LibGUI: Require a full click on ColorInput's color rect to open picker
Let's not open the ColorPicker on mousedown, that was too jarring.
This commit is contained in:
parent
8159f45f6e
commit
cdbc252190
2 changed files with 16 additions and 4 deletions
|
@ -71,9 +71,21 @@ void ColorInput::set_color(Color color)
|
|||
};
|
||||
|
||||
void ColorInput::mousedown_event(MouseEvent& event)
|
||||
{
|
||||
if (event.button() == MouseButton::Left && color_rect().contains(event.position())) {
|
||||
m_may_be_color_rect_click = true;
|
||||
return;
|
||||
}
|
||||
|
||||
TextEditor::mousedown_event(event);
|
||||
}
|
||||
|
||||
void ColorInput::mouseup_event(MouseEvent& event)
|
||||
{
|
||||
if (event.button() == MouseButton::Left) {
|
||||
if (is_enabled() && color_rect().contains(event.position())) {
|
||||
bool is_color_rect_click = m_may_be_color_rect_click && color_rect().contains(event.position());
|
||||
m_may_be_color_rect_click = false;
|
||||
if (is_color_rect_click) {
|
||||
auto dialog = GUI::ColorPicker::construct(m_color, window(), m_color_picker_title);
|
||||
dialog->set_color_has_alpha_channel(m_color_has_alpha_channel);
|
||||
if (dialog->exec() == GUI::Dialog::ExecOK)
|
||||
|
@ -82,8 +94,7 @@ void ColorInput::mousedown_event(MouseEvent& event)
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
TextEditor::mousedown_event(event);
|
||||
TextEditor::mouseup_event(event);
|
||||
}
|
||||
|
||||
void ColorInput::mousemove_event(MouseEvent& event)
|
||||
|
@ -109,5 +120,4 @@ void ColorInput::paint_event(PaintEvent& event)
|
|||
painter.fill_rect(color_rect(), m_color);
|
||||
painter.draw_rect(color_rect(), Color::Black);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue