Attempted to improve search behaviour.

Paper inputs don't fire `search` events, so listen for enter keyup
instead. However, there's something wrong with search in that I can't
get it to cycle through the matches any more. I tried to add the
findNext variable usage, but it doesn't seem to have had any effect.
This commit is contained in:
Oliver Hamlet
2014-11-09 22:04:27 +00:00
parent 6efe48d017
commit 8659cf03da
3 changed files with 17 additions and 10 deletions
+13 -3
View File
@@ -1069,7 +1069,16 @@ function hideHoverText(evt) {
}
}
function startSearch(evt) {
if (evt.target.value == '') {
var findNext = false;
if (evt.type == 'keyup') {
if (evt.keyCode != 13) {
// Don't do anything for keyboard events that aren't enter - if valid, the input event will handle them.
return;
} else {
findNext = true;
}
}
if (evt.target.inputValue == '') {
loot.query('cancelFind').then(function(result){
evt.target.focus();
}).catch(processCefError);
@@ -1077,7 +1086,8 @@ function startSearch(evt) {
var request = JSON.stringify({
name: 'find',
args: [
evt.target.value
evt.target.inputValue,
findNext
]
});
@@ -1153,7 +1163,7 @@ function setupEventHandlers() {
/* Set up event handlers for content search. */
var searchBox = document.getElementById('searchBox');
searchBox.addEventListener('input', startSearch, false);
searchBox.addEventListener('search', startSearch, false);
searchBox.addEventListener('keyup', startSearch, false);
window.addEventListener('keyup', focusSearch, false);
/* Set up handler for closing menus. */
+3 -6
View File
@@ -198,7 +198,7 @@ namespace loot {
if (requestName == "find") {
// Has one arg, which is the search string.
Find(browser, request["args"][0].as<string>());
Find(browser, request["args"][0].as<string>(), request["args"][1].as<bool>());
callback->Success("");
return true;
}
@@ -334,14 +334,11 @@ namespace loot {
return false;
}
void Handler::Find(CefRefPtr<CefBrowser> browser, const std::string& search) {
// In case there is a search already running, cancel it.
browser->GetHost()->StopFinding(true);
void Handler::Find(CefRefPtr<CefBrowser> browser, const std::string& search, bool findNext) {
// Only one search at a time is allowed, so give a constant identifier,
// and we want case-insensitive forward searching, with no repeated
// searches.
browser->GetHost()->Find(0, search, true, false, false);
browser->GetHost()->Find(0, search, true, false, findNext);
}
void Handler::GetConflictingPlugins(const std::string& pluginName, CefRefPtr<CefFrame> frame, CefRefPtr<Callback> callback) {
+1 -1
View File
@@ -66,7 +66,7 @@ namespace loot {
YAML::Node& request,
CefRefPtr<Callback> callback);
void Find(CefRefPtr<CefBrowser> browser, const std::string& search);
void Find(CefRefPtr<CefBrowser> browser, const std::string& search, bool findNext);
void GetConflictingPlugins(const std::string& pluginName, CefRefPtr<CefFrame> frame, CefRefPtr<Callback> callback);
void CopyMetadata(const std::string& pluginName);
std::string ClearPluginMetadata(const std::string& pluginName);