Author: stippi Date: Fri May 21 20:45:23 2010 New Revision: 513 URL: http://mmlr.dyndns.org/changeset/513 Log: 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. Modified: webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.cpp webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.h Modified: webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.cpp ============================================================================== --- webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.cpp Fri May 21 16:59:58 2010 (r512) +++ webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.cpp Fri May 21 20:45:23 2010 (r513) @@ -390,16 +390,21 @@ 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 @@ // 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 @@ } +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 { Modified: webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.h ============================================================================== --- webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.h Fri May 21 16:59:58 2010 (r512) +++ webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.h Fri May 21 20:45:23 2010 (r513) @@ -187,6 +187,7 @@ void _SetAutoHideInterfaceInFullscreen(bool doIt); void _CheckAutoHideInterface(); void _ShowInterface(bool show); + void _InvokeButtonVisibly(BButton* button); BString _NewTabURL(bool isNewWindow) const; @@ -220,6 +221,9 @@ BLayoutItem* fToggleFullscreenButton; BTextControl* fFindTextControl; + BButton* fFindPreviousButton; + BButton* fFindNextButton; + BButton* fFindCloseButton; BCheckBox* fFindCaseSensitiveCheckBox; TabManager* fTabManager;