mirror of
https://github.com/RGBCube/serenity
synced 2025-07-19 18:57:40 +00:00
GTextEditor: Don't replace selection on enter press in single-line editor.
This commit is contained in:
parent
3e7f33e4eb
commit
0e18201b7e
1 changed files with 6 additions and 5 deletions
|
@ -359,6 +359,12 @@ void GTextEditor::keydown_event(GKeyEvent& event)
|
||||||
if (is_single_line() && event.key() == KeyCode::Key_Tab)
|
if (is_single_line() && event.key() == KeyCode::Key_Tab)
|
||||||
return GWidget::keydown_event(event);
|
return GWidget::keydown_event(event);
|
||||||
|
|
||||||
|
if (is_single_line() && event.key() == KeyCode::Key_Return) {
|
||||||
|
if (on_return_pressed)
|
||||||
|
on_return_pressed();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (event.key() == KeyCode::Key_Escape) {
|
if (event.key() == KeyCode::Key_Escape) {
|
||||||
if (on_escape_pressed)
|
if (on_escape_pressed)
|
||||||
on_escape_pressed();
|
on_escape_pressed();
|
||||||
|
@ -600,11 +606,6 @@ void GTextEditor::insert_at_cursor(char ch)
|
||||||
bool at_head = m_cursor.column() == 0;
|
bool at_head = m_cursor.column() == 0;
|
||||||
bool at_tail = m_cursor.column() == current_line().length();
|
bool at_tail = m_cursor.column() == current_line().length();
|
||||||
if (ch == '\n') {
|
if (ch == '\n') {
|
||||||
if (is_single_line()) {
|
|
||||||
if (on_return_pressed)
|
|
||||||
on_return_pressed();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (at_tail || at_head) {
|
if (at_tail || at_head) {
|
||||||
String new_line_contents;
|
String new_line_contents;
|
||||||
if (m_automatic_indentation_enabled && at_tail) {
|
if (m_automatic_indentation_enabled && at_tail) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue