nat_linden avatar nat_linden committed 142d90a

STEAM-14: login when user presses Enter at username or password.
The tricky thing about this fix is that the "Log In" button used to be in the
same layout_panel as the username and password fields. Now it's not, so the
fact that it's the default button for its layout_panel doesn't matter because
that layout_panel doesn't have focus. Richard pointed out that we can make the
commit action for the username and password fields initiate login -- as long
as neither field implicitly runs its commit action when it loses focus!

Comments (0)

Files changed (2)

indra/newview/llpanellogin.cpp

 	mLogoImage = LLUI::getUIImage("startup_logo");
 
 	buildFromFile( "panel_login.xml");
-	
+
 	reshape(rect.getWidth(), rect.getHeight());
 
-	getChild<LLLineEditor>("password_edit")->setKeystrokeCallback(onPassKey, this);
+	LLLineEditor* password_edit(getChild<LLLineEditor>("password_edit"));
+	password_edit->setKeystrokeCallback(onPassKey, this);
+	// STEAM-14: When user presses Enter with this field in focus, initiate login
+	password_edit->setCommitCallback(boost::bind(&LLPanelLogin::onClickConnect, this));
 
 	// change z sort of clickable text to be behind buttons
 	sendChildToBack(getChildView("forgot_password_text"));
-	
+
 	LLComboBox* location_combo = getChild<LLComboBox>("start_location_combo");
 	updateLocationSelectorsVisibility(); // separate so that it can be called from preferences
 	location_combo->setFocusLostCallback(boost::bind(&LLPanelLogin::onLocationSLURL, this));
 	// get the web browser control
 	LLMediaCtrl* web_browser = getChild<LLMediaCtrl>("login_html");
 	web_browser->addObserver(this);
-	
+
 	reshapeBrowser();
 
 	loadLoginPage();
-			
+
 	// Show last logged in user favorites in "Start at" combo.
 	addUsersWithFavoritesToUsername();
-	getChild<LLComboBox>("username_combo")->setTextChangedCallback(boost::bind(&LLPanelLogin::addFavoritesToStartLocation, this));
+	LLComboBox* username_combo(getChild<LLComboBox>("username_combo"));
+	username_combo->setTextChangedCallback(boost::bind(&LLPanelLogin::addFavoritesToStartLocation, this));
+	// STEAM-14: When user presses Enter with this field in focus, initiate login
+	username_combo->setCommitCallback(boost::bind(&LLPanelLogin::onClickConnect, this));
 }
 
 void LLPanelLogin::addUsersWithFavoritesToUsername()

indra/newview/skins/default/xui/en/panel_login.xml

           width="150">
         Username:
       </text>
+      <!-- STEAM-14: Turn off commit_on_focus_lost so if user presses Enter
+           with focus in this combo_box, we can use commit action to initiate
+           login -->
       <combo_box
           allow_text_entry="true"
           follows="left|bottom"
           height="22"
           left_delta="0"
           max_chars="128"
+          commit_on_focus_lost="false"
           combo_editor.prevalidate_callback="ascii"
           tool_tip="The username you chose when you registered, like bobsmith12 or Steller Sunshine"
           top_pad="0"
           width="150">
         Password:
       </text>
+      <!-- STEAM-14: Turn off commit_on_focus_lost so if user presses Enter
+           with focus in this line_editor, we can use commit action to
+           initiate login -->
       <line_editor
           follows="left|bottom"
           height="22"
           name="password_edit"
           is_password="true" 
           select_on_focus="true"
+          commit_on_focus_lost="false"
           top_pad="0"
           width="135" />
     </layout_panel>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.