Focus search field in web search after switching from a different search tab

meow-7.2.2
Ansariel 2016-10-25 15:30:07 +02:00
parent fce13293a3
commit 294c08bb03
2 changed files with 26 additions and 4 deletions

View File

@ -315,16 +315,22 @@ BOOL FSFloaterSearch::postBuild()
mDetailMaturity = getChild<LLIconCtrl>("maturity_icon");
mTabContainer = getChild<LLTabContainer>("ls_tabs");
if (mTabContainer)
{
mTabContainer->setCommitCallback(boost::bind(&FSFloaterSearch::onTabChange, this));
}
flushDetails();
if (mDetailsPanel)
{
mDetailsPanel->setVisible(false);
}
mHasSelection = false;
if (!mTabContainer->selectTab(gSavedSettings.getS32("FSLastSearchTab")))
{
mTabContainer->selectFirstTab();
}
return TRUE;
}
@ -333,9 +339,10 @@ void FSFloaterSearch::onTabChange()
{
LLPanel* active_panel = mTabContainer->getCurrentPanel();
if(active_panel == mPanelWeb)
if (active_panel == mPanelWeb)
{
mDetailsPanel->setVisible(false);
mPanelWeb->resetFocusOnLoad();
}
else
{
@ -2664,6 +2671,7 @@ static LLPanelInjector<FSPanelSearchWeb> t_panel_fs_search_web("panel_ls_web");
FSPanelSearchWeb::FSPanelSearchWeb() : FSSearchPanelBase()
, mWebBrowser(NULL)
, mResetFocusOnLoad(false)
{
// declare a map that transforms a category name into
// the URL suffix that is used to search that category
@ -2681,8 +2689,7 @@ FSPanelSearchWeb::FSPanelSearchWeb() : FSSearchPanelBase()
BOOL FSPanelSearchWeb::postBuild()
{
mWebBrowser = getChild<LLMediaCtrl>("search_browser");
if (mWebBrowser) mWebBrowser->addObserver(this);
return TRUE;
return TRUE;
}
void FSPanelSearchWeb::loadURL(const SearchQuery &p)
@ -2750,6 +2757,17 @@ void FSPanelSearchWeb::focusDefaultElement()
mWebBrowser->setFocus(TRUE);
}
void FSPanelSearchWeb::draw()
{
if (mResetFocusOnLoad)
{
focusDefaultElement();
mResetFocusOnLoad = false;
}
FSSearchPanelBase::draw();
}
////////////////////////////////////////
// Local functions //
////////////////////////////////////////

View File

@ -299,7 +299,7 @@ private:
LLRadioGroup* mEventsMode;
};
class FSPanelSearchWeb : public FSSearchPanelBase, public LLViewerMediaObserver
class FSPanelSearchWeb : public FSSearchPanelBase
{
LOG_CLASS(FSFloaterSearch);
public:
@ -307,12 +307,16 @@ public:
/*virtual*/ BOOL postBuild();
void loadURL(const SearchQuery &query);
/*virtual*/ void focusDefaultElement();
/*virtual*/ void draw();
void resetFocusOnLoad() { mResetFocusOnLoad = true; }
private:
virtual ~FSPanelSearchWeb() {};
LLMediaCtrl* mWebBrowser;
LLSD mCategoryPaths;
bool mResetFocusOnLoad;
};
class FSFloaterSearch : public LLFloater