[feat] let keyboard focus on input widget when needs to input password

This commit is contained in:
dijunkun
2024-08-19 11:05:08 +08:00
parent 070b48d7a7
commit 72fda8a728
2 changed files with 9 additions and 0 deletions

View File

@@ -81,10 +81,16 @@ int Render::ConnectionStatusWindow() {
ImGui::SetNextItemWidth(IPUT_WINDOW_WIDTH / 2); ImGui::SetNextItemWidth(IPUT_WINDOW_WIDTH / 2);
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0f); ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0f);
if (focus_on_input_widget_) {
ImGui::SetKeyboardFocusHere();
focus_on_input_widget_ = false;
}
bool enter_pressed = bool enter_pressed =
ImGui::InputText("##password", (char *)remote_password_.c_str(), 7, ImGui::InputText("##password", (char *)remote_password_.c_str(), 7,
ImGuiInputTextFlags_CharsNoBlank | ImGuiInputTextFlags_CharsNoBlank |
ImGuiInputTextFlags_EnterReturnsTrue); ImGuiInputTextFlags_EnterReturnsTrue);
ImGui::PopStyleVar(); ImGui::PopStyleVar();
ImGui::SetCursorPosX(window_width * 0.315f); ImGui::SetCursorPosX(window_width * 0.315f);
@@ -96,6 +102,7 @@ int Render::ConnectionStatusWindow() {
show_connection_status_window_ = true; show_connection_status_window_ = true;
password_validating_ = true; password_validating_ = true;
rejoin_ = true; rejoin_ = true;
focus_on_input_widget_ = true;
} }
ImGui::SameLine(); ImGui::SameLine();
@@ -104,6 +111,7 @@ int Render::ConnectionStatusWindow() {
localization::cancel[localization_language_index_].c_str())) { localization::cancel[localization_language_index_].c_str())) {
remote_password_ = ""; remote_password_ = "";
show_connection_status_window_ = false; show_connection_status_window_ = false;
focus_on_input_widget_ = true;
} }
} else { } else {
text = localization::validate_password[localization_language_index_]; text = localization::validate_password[localization_language_index_];

View File

@@ -202,6 +202,7 @@ class Render {
bool regenerate_password_ = false; bool regenerate_password_ = false;
bool show_about_window_ = false; bool show_about_window_ = false;
bool show_connection_status_window_ = false; bool show_connection_status_window_ = false;
bool focus_on_input_widget_ = true;
bool window_maximized_ = false; bool window_maximized_ = false;
bool streaming_ = false; bool streaming_ = false;
bool is_client_mode_ = false; bool is_client_mode_ = false;