1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 03:07:43 +00:00

Add TextBox::onReturnPressed.

This commit is contained in:
Andreas Kling 2018-10-13 23:19:44 +02:00
parent 7a0a7abc52
commit d305c316e1
5 changed files with 14 additions and 1 deletions

View file

@ -56,7 +56,7 @@ void TextBox::paintEvent(PaintEvent&)
painter.drawBitmap({x, y}, *bitmap, Color::Black);
}
if (m_cursorBlinkState) {
if (isFocused() && m_cursorBlinkState) {
unsigned visibleCursorPosition = m_cursorPosition - firstVisibleChar;
Rect cursorRect(innerRect.x() + visibleCursorPosition * font.glyphWidth(), innerRect.y(), 1, innerRect.height());
painter.fillRect(cursorRect, foregroundColor());
@ -107,6 +107,10 @@ void TextBox::keyDownEvent(KeyEvent& event)
return;
case KeyboardKey::Backspace:
return handleBackspace();
case KeyboardKey::Return:
if (onReturnPressed)
onReturnPressed(*this);
return;
}
if (!event.text().isEmpty()) {