From 5c87c43007d975e55da449e2c3781abda7cd82ce Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 9 Feb 2026 14:02:36 +0400 Subject: [PATCH] Conditionally handle Tab in fields in custom way. --- Telegram/SourceFiles/boxes/add_contact_box.cpp | 9 ++++----- Telegram/SourceFiles/boxes/create_poll_box.cpp | 12 ++++++------ Telegram/SourceFiles/boxes/edit_todo_list_box.cpp | 9 ++++----- .../chat_helpers/field_autocomplete.cpp | 4 ++-- .../SourceFiles/chat_helpers/message_field.cpp | 10 +++++----- Telegram/SourceFiles/history/history_widget.cpp | 15 +++++---------- Telegram/SourceFiles/history/history_widget.h | 1 - Telegram/lib_ui | 2 +- 8 files changed, 27 insertions(+), 35 deletions(-) diff --git a/Telegram/SourceFiles/boxes/add_contact_box.cpp b/Telegram/SourceFiles/boxes/add_contact_box.cpp index b863ff2e28..c6becf7bc1 100644 --- a/Telegram/SourceFiles/boxes/add_contact_box.cpp +++ b/Telegram/SourceFiles/boxes/add_contact_box.cpp @@ -1571,16 +1571,15 @@ void EditNameBox::prepare() { _last->submits( ) | rpl::on_next([=] { submit(); }, _last->lifetime()); - _first->customTab(true); - _last->customTab(true); - _first->tabbed( - ) | rpl::on_next([=] { + ) | rpl::on_next([=](not_null handled) { _last->setFocus(); + *handled = true; }, _first->lifetime()); _last->tabbed( - ) | rpl::on_next([=] { + ) | rpl::on_next([=](not_null handled) { _first->setFocus(); + *handled = true; }, _last->lifetime()); } diff --git a/Telegram/SourceFiles/boxes/create_poll_box.cpp b/Telegram/SourceFiles/boxes/create_poll_box.cpp index d885b2ca06..1b7751b70b 100644 --- a/Telegram/SourceFiles/boxes/create_poll_box.cpp +++ b/Telegram/SourceFiles/boxes/create_poll_box.cpp @@ -246,7 +246,6 @@ Options::Option::Option( InitField(outer, _field, session); _field->setMaxLength(kOptionLimit + kErrorLimit); _field->show(); - _field->customTab(true); _wrap->hide(anim::type::instant); @@ -725,13 +724,14 @@ void Options::addEmptyOption() { _scrollToWidget.fire_copy(field); }, field->lifetime()); field->tabbed( - ) | rpl::on_next([=] { + ) | rpl::on_next([=](not_null handled) { const auto index = findField(field); if (index + 1 < _list.size()) { _list[index + 1]->setFocus(); } else { _tabbed.fire({}); } + *handled = true; }, field->lifetime()); base::install_event_filter(field, [=](not_null event) { if (event->type() != QEvent::KeyPress @@ -863,7 +863,6 @@ not_null CreatePollBox::setupQuestion( InitField(getDelegate()->outerContainer(), question, session); question->setMaxLength(kQuestionLimit + kErrorLimit); question->setSubmitSettings(Ui::InputField::SubmitSettings::Both); - question->customTab(true); if (isPremium) { using Selector = ChatHelpers::TabbedSelector; @@ -968,7 +967,6 @@ not_null CreatePollBox::setupSolution( )); solution->setEditLinkCallback( DefaultEditLinkCallback(_controller->uiShow(), solution)); - solution->customTab(true); const auto warning = CreateWarningLabel( inner, @@ -1048,8 +1046,9 @@ object_ptr CreatePollBox::setupContent() { st::createPollLimitPadding)); question->tabbed( - ) | rpl::on_next([=] { + ) | rpl::on_next([=](not_null handled) { options->focusFirst(); + *handled = true; }, question->lifetime()); Ui::AddSkip(container); @@ -1097,8 +1096,9 @@ object_ptr CreatePollBox::setupContent() { }, question->lifetime()); solution->tabbed( - ) | rpl::on_next([=] { + ) | rpl::on_next([=](not_null handled) { question->setFocus(); + *handled = true; }, solution->lifetime()); quiz->setDisabled(_disabled & PollData::Flag::Quiz); diff --git a/Telegram/SourceFiles/boxes/edit_todo_list_box.cpp b/Telegram/SourceFiles/boxes/edit_todo_list_box.cpp index acf1f03859..59960a2f47 100644 --- a/Telegram/SourceFiles/boxes/edit_todo_list_box.cpp +++ b/Telegram/SourceFiles/boxes/edit_todo_list_box.cpp @@ -303,8 +303,6 @@ Tasks::Task::Task( _field->show(); if (locked) { _field->setDisabled(true); - } else { - _field->customTab(true); } _wrap->hide(anim::type::instant); @@ -766,13 +764,14 @@ void Tasks::initTaskField(not_null task, TextWithEntities text) { _scrollToWidget.fire_copy(field); }, field->lifetime()); field->tabbed( - ) | rpl::on_next([=] { + ) | rpl::on_next([=](not_null handled) { const auto index = findField(field); if (index + 1 < _list.size()) { _list[index + 1]->setFocus(); } else { _tabbed.fire({}); } + *handled = true; }, field->lifetime()); base::install_event_filter(field, [=](not_null event) { if (event->type() != QEvent::KeyPress @@ -933,7 +932,6 @@ not_null EditTodoListBox::setupTitle( InitField(getDelegate()->outerContainer(), title, session); title->setMaxLength(_titleLimit + kErrorLimit); title->setSubmitSettings(Ui::InputField::SubmitSettings::Both); - title->customTab(true); if (isPremium) { _emojiPanel = MakeEmojiPanel( @@ -1044,8 +1042,9 @@ object_ptr EditTodoListBox::setupContent() { st::createPollLimitPadding)); title->tabbed( - ) | rpl::on_next([=] { + ) | rpl::on_next([=](not_null handled) { tasks->focusFirst(); + *handled = true; }, title->lifetime()); Ui::AddSkip(container); diff --git a/Telegram/SourceFiles/chat_helpers/field_autocomplete.cpp b/Telegram/SourceFiles/chat_helpers/field_autocomplete.cpp index eceea7ee3e..13a1aa583d 100644 --- a/Telegram/SourceFiles/chat_helpers/field_autocomplete.cpp +++ b/Telegram/SourceFiles/chat_helpers/field_autocomplete.cpp @@ -1662,7 +1662,6 @@ void InitFieldAutocomplete( const auto field = descriptor.field; field->rawTextEdit()->installEventFilter(raw); - field->customTab(true); raw->mentionChosen( ) | rpl::on_next([=](FieldAutocomplete::MentionChosen data) { @@ -1727,9 +1726,10 @@ void InitFieldAutocomplete( } field->tabbed( - ) | rpl::on_next([=] { + ) | rpl::on_next([=](not_null handled) { if (!raw->isHidden()) { raw->chooseSelected(FieldAutocomplete::ChooseMethod::ByTab); + *handled = true; } }, raw->lifetime()); diff --git a/Telegram/SourceFiles/chat_helpers/message_field.cpp b/Telegram/SourceFiles/chat_helpers/message_field.cpp index f1cb8d9412..a7bed86483 100644 --- a/Telegram/SourceFiles/chat_helpers/message_field.cpp +++ b/Telegram/SourceFiles/chat_helpers/message_field.cpp @@ -244,9 +244,6 @@ void EditLinkBox( } }); - url->customTab(true); - text->customTab(true); - const auto clearFullSelection = [=](not_null input) { if (input->empty()) { return; @@ -262,17 +259,20 @@ void EditLinkBox( }; url->tabbed( - ) | rpl::on_next([=] { + ) | rpl::on_next([=](not_null handled) { clearFullSelection(url); text->setFocus(); + *handled = true; }, url->lifetime()); + text->tabbed( - ) | rpl::on_next([=] { + ) | rpl::on_next([=](not_null handled) { if (!url->empty()) { url->selectAll(); } clearFullSelection(text); url->setFocus(); + *handled = true; }, text->lifetime()); } diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index f80d93d364..ed1e80a4b2 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -409,8 +409,11 @@ HistoryWidget::HistoryWidget( escape(); }, _field->lifetime()); _field->tabbed( - ) | rpl::on_next([=] { - fieldTabbed(); + ) | rpl::on_next([=](not_null handled) { + if (_supportAutocomplete) { + _supportAutocomplete->activate(_field.data()); + *handled = true; + } }, _field->lifetime()); _field->heightChanges( ) | rpl::on_next([=] { @@ -7881,14 +7884,6 @@ bool HistoryWidget::showSlowmodeError() { return true; } -void HistoryWidget::fieldTabbed() { - if (_supportAutocomplete) { - _supportAutocomplete->activate(_field.data()); - }else{ - focusNextPrevChild(true); - } -} - void HistoryWidget::sendInlineResult(InlineBots::ResultSelected result) { if (!_peer || !_canSendMessages) { return; diff --git a/Telegram/SourceFiles/history/history_widget.h b/Telegram/SourceFiles/history/history_widget.h index 5b4f65b0c1..214de7054d 100644 --- a/Telegram/SourceFiles/history/history_widget.h +++ b/Telegram/SourceFiles/history/history_widget.h @@ -388,7 +388,6 @@ private: void setTabbedPanel(std::unique_ptr panel); void updateField(); void fieldChanged(); - void fieldTabbed(); void fieldFocused(); void fieldResized(); diff --git a/Telegram/lib_ui b/Telegram/lib_ui index a511dcce33..9031f0f5e0 160000 --- a/Telegram/lib_ui +++ b/Telegram/lib_ui @@ -1 +1 @@ -Subproject commit a511dcce33d20b92777ef697823f864481964c55 +Subproject commit 9031f0f5e0248cd0b9b907f42980d593dfb57ff7