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:
committed by
Alexandre Deckner
parent
fb03e2c573
commit
8a48f074d8
@@ -390,16 +390,21 @@ BrowserWindow::BrowserWindow(BRect frame, SettingsMessage* appSettings,
|
|||||||
fFindTextControl = new BTextControl("find", "Find:", "",
|
fFindTextControl = new BTextControl("find", "Find:", "",
|
||||||
new BMessage(EDIT_FIND_NEXT));
|
new BMessage(EDIT_FIND_NEXT));
|
||||||
fFindTextControl->SetModificationMessage(new BMessage(FIND_TEXT_CHANGED));
|
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");
|
fFindCaseSensitiveCheckBox = new BCheckBox("Match case");
|
||||||
BView* findGroup = BGroupLayoutBuilder(B_VERTICAL)
|
BView* findGroup = BGroupLayoutBuilder(B_VERTICAL)
|
||||||
.Add(new BSeparatorView(B_HORIZONTAL, B_PLAIN_BORDER))
|
.Add(new BSeparatorView(B_HORIZONTAL, B_PLAIN_BORDER))
|
||||||
.Add(BGroupLayoutBuilder(B_HORIZONTAL, kElementSpacing)
|
.Add(BGroupLayoutBuilder(B_HORIZONTAL, kElementSpacing)
|
||||||
.Add(fFindTextControl)
|
.Add(fFindTextControl)
|
||||||
.Add(new BButton("Previous", new BMessage(EDIT_FIND_PREVIOUS)))
|
.Add(fFindPreviousButton)
|
||||||
.Add(new BButton("Next", new BMessage(EDIT_FIND_NEXT)))
|
.Add(fFindNextButton)
|
||||||
.Add(fFindCaseSensitiveCheckBox)
|
.Add(fFindCaseSensitiveCheckBox)
|
||||||
.Add(BSpaceLayoutItem::CreateGlue())
|
.Add(BSpaceLayoutItem::CreateGlue())
|
||||||
.Add(new BButton("Close", new BMessage(EDIT_HIDE_FIND_GROUP)))
|
.Add(fFindCloseButton)
|
||||||
.SetInsets(kInsetSpacing, kInsetSpacing,
|
.SetInsets(kInsetSpacing, kInsetSpacing,
|
||||||
kInsetSpacing, kInsetSpacing)
|
kInsetSpacing, kInsetSpacing)
|
||||||
)
|
)
|
||||||
@@ -538,11 +543,19 @@ BrowserWindow::DispatchMessage(BMessage* message, BHandler* target)
|
|||||||
// when the text control just goes out of focus.
|
// when the text control just goes out of focus.
|
||||||
if (bytes[0] == B_RETURN) {
|
if (bytes[0] == B_RETURN) {
|
||||||
// Do it in such a way that the user sees the Go-button go down.
|
// Do it in such a way that the user sees the Go-button go down.
|
||||||
fURLInputGroup->GoButton()->SetValue(B_CONTROL_ON);
|
_InvokeButtonVisibly(fURLInputGroup->GoButton());
|
||||||
UpdateIfNeeded();
|
return;
|
||||||
fURLInputGroup->GoButton()->Invoke();
|
}
|
||||||
snooze(1000);
|
} else if (target == fFindTextControl->TextView()) {
|
||||||
fURLInputGroup->GoButton()->SetValue(B_CONTROL_OFF);
|
// 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;
|
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
|
BString
|
||||||
BrowserWindow::_NewTabURL(bool isNewWindow) const
|
BrowserWindow::_NewTabURL(bool isNewWindow) const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -187,6 +187,7 @@ private:
|
|||||||
void _SetAutoHideInterfaceInFullscreen(bool doIt);
|
void _SetAutoHideInterfaceInFullscreen(bool doIt);
|
||||||
void _CheckAutoHideInterface();
|
void _CheckAutoHideInterface();
|
||||||
void _ShowInterface(bool show);
|
void _ShowInterface(bool show);
|
||||||
|
void _InvokeButtonVisibly(BButton* button);
|
||||||
|
|
||||||
BString _NewTabURL(bool isNewWindow) const;
|
BString _NewTabURL(bool isNewWindow) const;
|
||||||
|
|
||||||
@@ -220,6 +221,9 @@ private:
|
|||||||
BLayoutItem* fToggleFullscreenButton;
|
BLayoutItem* fToggleFullscreenButton;
|
||||||
|
|
||||||
BTextControl* fFindTextControl;
|
BTextControl* fFindTextControl;
|
||||||
|
BButton* fFindPreviousButton;
|
||||||
|
BButton* fFindNextButton;
|
||||||
|
BButton* fFindCloseButton;
|
||||||
BCheckBox* fFindCaseSensitiveCheckBox;
|
BCheckBox* fFindCaseSensitiveCheckBox;
|
||||||
TabManager* fTabManager;
|
TabManager* fTabManager;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user