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
Родитель c9c3c05646
Коммит 618c586548
2 изменённых файлов: 11 добавлений и 0 удалений

Просмотреть файл

@ -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);

Просмотреть файл

@ -191,6 +191,11 @@ public: //for methods who access nsTextControlFrame directly
mHasFocus = aHasFocus;
};
PRBool GetHasFocus() const
{
return mHasFocus;
}
/* called to free up native keybinding services */
static NS_HIDDEN_(void) ShutDown();