Handle B_RETURN and B_ESCAPE when the Find text control has focus. Refactored

the code to visibly invoke a BButton and use it to show the respective buttons
go down in the Find group.

git-svn-id: http://svn.haiku-os.org/webpositive/webkit/trunk@513 94f232f2-1747-11df-bad5-a5bfde151594
This commit is contained in:
stippi 2010-05-21 20:45:23 +00:00 committed by Alexandre Deckner
parent fb03e2c573
commit 8a48f074d8
2 changed files with 36 additions and 8 deletions

View File

@ -390,16 +390,21 @@ BrowserWindow::BrowserWindow(BRect frame, SettingsMessage* appSettings,
fFindTextControl = new BTextControl("find", "Find:", "",
new BMessage(EDIT_FIND_NEXT));
fFindTextControl->SetModificationMessage(new BMessage(FIND_TEXT_CHANGED));
fFindPreviousButton = new BButton("Previous",
new BMessage(EDIT_FIND_PREVIOUS));
fFindNextButton = new BButton("Next", new BMessage(EDIT_FIND_NEXT));
fFindCloseButton = new BButton("Close",
new BMessage(EDIT_HIDE_FIND_GROUP));
fFindCaseSensitiveCheckBox = new BCheckBox("Match case");
BView* findGroup = BGroupLayoutBuilder(B_VERTICAL)
.Add(new BSeparatorView(B_HORIZONTAL, B_PLAIN_BORDER))
.Add(BGroupLayoutBuilder(B_HORIZONTAL, kElementSpacing)
.Add(fFindTextControl)
.Add(new BButton("Previous", new BMessage(EDIT_FIND_PREVIOUS)))
.Add(new BButton("Next", new BMessage(EDIT_FIND_NEXT)))
.Add(fFindPreviousButton)
.Add(fFindNextButton)
.Add(fFindCaseSensitiveCheckBox)
.Add(BSpaceLayoutItem::CreateGlue())
.Add(new BButton("Close", new BMessage(EDIT_HIDE_FIND_GROUP)))
.Add(fFindCloseButton)
.SetInsets(kInsetSpacing, kInsetSpacing,
kInsetSpacing, kInsetSpacing)
)
@ -538,11 +543,19 @@ BrowserWindow::DispatchMessage(BMessage* message, BHandler* target)
// when the text control just goes out of focus.
if (bytes[0] == B_RETURN) {
// Do it in such a way that the user sees the Go-button go down.
fURLInputGroup->GoButton()->SetValue(B_CONTROL_ON);
UpdateIfNeeded();
fURLInputGroup->GoButton()->Invoke();
snooze(1000);
fURLInputGroup->GoButton()->SetValue(B_CONTROL_OFF);
_InvokeButtonVisibly(fURLInputGroup->GoButton());
return;
}
} else if (target == fFindTextControl->TextView()) {
// Handle B_RETURN when the find text control has focus.
if (bytes[0] == B_RETURN) {
if ((modifiers & B_SHIFT_KEY) != 0)
_InvokeButtonVisibly(fFindPreviousButton);
else
_InvokeButtonVisibly(fFindNextButton);
return;
} else if (bytes[0] == B_ESCAPE) {
_InvokeButtonVisibly(fFindCloseButton);
return;
}
}
@ -1978,6 +1991,17 @@ BrowserWindow::_ShowInterface(bool show)
}
void
BrowserWindow::_InvokeButtonVisibly(BButton* button)
{
button->SetValue(B_CONTROL_ON);
UpdateIfNeeded();
button->Invoke();
snooze(1000);
button->SetValue(B_CONTROL_OFF);
}
BString
BrowserWindow::_NewTabURL(bool isNewWindow) const
{

View File

@ -187,6 +187,7 @@ private:
void _SetAutoHideInterfaceInFullscreen(bool doIt);
void _CheckAutoHideInterface();
void _ShowInterface(bool show);
void _InvokeButtonVisibly(BButton* button);
BString _NewTabURL(bool isNewWindow) const;
@ -220,6 +221,9 @@ private:
BLayoutItem* fToggleFullscreenButton;
BTextControl* fFindTextControl;
BButton* fFindPreviousButton;
BButton* fFindNextButton;
BButton* fFindCloseButton;
BCheckBox* fFindCaseSensitiveCheckBox;
TabManager* fTabManager;