When setting the textfield value via the filepicker, tell it that it's not

focused so that onchange will fire as it should.  Bug 355362, r+sr=jst
This commit is contained in:
bzbarsky@mit.edu
2006-10-15 15:39:35 +00:00
parent 12b735be5e
commit 508e7cdfe0
2 changed files with 11 additions and 0 deletions

View File

@@ -318,7 +318,13 @@ nsFileControlFrame::MouseClick(nsIDOMEvent* aMouseEvent)
nsAutoString unicodePath;
result = localFile->GetPath(unicodePath);
if (!unicodePath.IsEmpty()) {
// Tell mTextFrame that it doesn't have focus while we're setting the
// value. Otherwise it'll think that the value is being set by a script
// while it has focus and not fire onchange when it should.
PRBool hasFocus = mTextFrame->GetHasFocus();
mTextFrame->SetHasFocus(PR_FALSE);
mTextFrame->SetFormProperty(nsHTMLAtoms::value, unicodePath);
mTextFrame->SetHasFocus(hasFocus);
nsCOMPtr<nsIFileControlElement> fileControl = do_QueryInterface(mContent);
if (fileControl) {
fileControl->SetFileName(unicodePath);