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:
parent
927bc248a3
commit
a9112961b9
@ -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()) {
|
||||
|
@ -43,6 +43,8 @@ private:
|
||||
private:
|
||||
BTextView* fTextView;
|
||||
bool fModificationsReported;
|
||||
BString fOriginalText;
|
||||
bool fOriginalTextSaved;
|
||||
};
|
||||
|
||||
#endif // TEXT_CONTROL_COMPLETER_H
|
||||
|
Loading…
Reference in New Issue
Block a user