mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:28:12 +00:00
LibGUI: GTextBox should only run a caret blink timer when focused.
This commit is contained in:
parent
c0cffe1134
commit
bc6ff35428
3 changed files with 14 additions and 2 deletions
|
@ -8,7 +8,6 @@
|
||||||
GTextBox::GTextBox(GWidget* parent)
|
GTextBox::GTextBox(GWidget* parent)
|
||||||
: GWidget(parent)
|
: GWidget(parent)
|
||||||
{
|
{
|
||||||
start_timer(500);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GTextBox::~GTextBox()
|
GTextBox::~GTextBox()
|
||||||
|
@ -138,3 +137,13 @@ void GTextBox::timer_event(GTimerEvent&)
|
||||||
m_cursor_blink_state = !m_cursor_blink_state;
|
m_cursor_blink_state = !m_cursor_blink_state;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GTextBox::focusin_event(GEvent&)
|
||||||
|
{
|
||||||
|
start_timer(500);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GTextBox::focusout_event(GEvent&)
|
||||||
|
{
|
||||||
|
stop_timer();
|
||||||
|
}
|
||||||
|
|
|
@ -20,6 +20,8 @@ private:
|
||||||
virtual void mousedown_event(GMouseEvent&) override;
|
virtual void mousedown_event(GMouseEvent&) override;
|
||||||
virtual void keydown_event(GKeyEvent&) override;
|
virtual void keydown_event(GKeyEvent&) override;
|
||||||
virtual void timer_event(GTimerEvent&) override;
|
virtual void timer_event(GTimerEvent&) override;
|
||||||
|
virtual void focusin_event(GEvent&) override;
|
||||||
|
virtual void focusout_event(GEvent&) override;
|
||||||
virtual bool accepts_focus() const override { return true; }
|
virtual bool accepts_focus() const override { return true; }
|
||||||
|
|
||||||
void handle_backspace();
|
void handle_backspace();
|
||||||
|
|
|
@ -39,8 +39,9 @@ void GWidget::event(GEvent& event)
|
||||||
m_has_pending_paint_event = false;
|
m_has_pending_paint_event = false;
|
||||||
return paint_event(static_cast<GPaintEvent&>(event));
|
return paint_event(static_cast<GPaintEvent&>(event));
|
||||||
case GEvent::FocusIn:
|
case GEvent::FocusIn:
|
||||||
case GEvent::FocusOut:
|
|
||||||
return focusin_event(event);
|
return focusin_event(event);
|
||||||
|
case GEvent::FocusOut:
|
||||||
|
return focusout_event(event);
|
||||||
case GEvent::Show:
|
case GEvent::Show:
|
||||||
return show_event(static_cast<GShowEvent&>(event));
|
return show_event(static_cast<GShowEvent&>(event));
|
||||||
case GEvent::Hide:
|
case GEvent::Hide:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue