Restore the original URL text when the escape key is pressed.

git-svn-id: http://svn.haiku-os.org/webpositive/webkit/trunk@563 94f232f2-1747-11df-bad5-a5bfde151594
This commit is contained in:
leavengood 2010-12-29 22:51:13 +00:00 committed by Alexandre Deckner
parent 927bc248a3
commit a9112961b9
2 changed files with 16 additions and 2 deletions

View File

@ -73,7 +73,8 @@ TextViewCompleter::TextViewCompleter(BTextView* textView, ChoiceModel* model,
new BDefaultChoiceView(), patternSelector),
BMessageFilter(B_KEY_DOWN),
fTextView(textView),
fModificationsReported(false)
fModificationsReported(false),
fOriginalTextSaved(false)
{
fTextView->AddFilter(this);
}
@ -102,6 +103,11 @@ TextViewCompleter::TextModified(bool updateChoices)
filter_result
TextViewCompleter::Filter(BMessage* message, BHandler** target)
{
if (!fOriginalTextSaved) {
fOriginalText = fTextView->Text();
fOriginalTextSaved = true;
}
const char* bytes;
int32 modifiers;
if (!target || message->FindString("bytes", &bytes) != B_OK
@ -140,7 +146,13 @@ TextViewCompleter::Filter(BMessage* message, BHandler** target)
}
case B_ESCAPE:
CancelChoice();
if (fOriginalText != fTextView->Text()) {
fModificationsReported = false;
fTextView->SetText(fOriginalText.String());
fTextView->SelectAll();
fModificationsReported = true;
CancelChoice();
}
return B_SKIP_MESSAGE;
case B_RETURN:
if (IsChoiceSelected()) {

View File

@ -43,6 +43,8 @@ private:
private:
BTextView* fTextView;
bool fModificationsReported;
BString fOriginalText;
bool fOriginalTextSaved;
};
#endif // TEXT_CONTROL_COMPLETER_H