Added ability to jump from code to phone input in intro with Space.

This commit is contained in:
23rd 2025-05-15 18:19:49 +03:00
parent 018f147de6
commit 71f34f4e31
3 changed files with 16 additions and 0 deletions

View file

@ -80,6 +80,9 @@ PhoneWidget::PhoneWidget(
) | rpl::start_with_next([=](const QString &added) {
_phone->addedToNumber(added);
}, _phone->lifetime());
_code->spacePressed() | rpl::start_with_next([=] {
submit();
}, _code->lifetime());
connect(_phone, &Ui::PhonePartInput::changed, [=] { phoneChanged(); });
connect(_code, &Ui::CountryCodeInput::changed, [=] { phoneChanged(); });

View file

@ -50,6 +50,14 @@ void CountryCodeInput::codeSelected(const QString &code) {
changed();
}
void CountryCodeInput::keyPressEvent(QKeyEvent *e) {
if (e->key() == Qt::Key_Space) {
_spacePressed.fire({});
} else {
MaskedInputField::keyPressEvent(e);
}
}
void CountryCodeInput::correctValue(
const QString &was,
int wasCursor,

View file

@ -23,10 +23,14 @@ public:
[[nodiscard]] rpl::producer<QString> codeChanged() const {
return _codeChanged.events();
}
[[nodiscard]] rpl::producer<> spacePressed() const {
return _spacePressed.events();
}
void codeSelected(const QString &code);
protected:
void keyPressEvent(QKeyEvent *e) override;
void correctValue(
const QString &was,
int wasCursor,
@ -37,6 +41,7 @@ private:
bool _nosignal = false;
rpl::event_stream<QString> _addedToNumber;
rpl::event_stream<QString> _codeChanged;
rpl::event_stream<> _spacePressed;
};