mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
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:
@@ -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
@@ -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
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user