mirror of
https://github.com/smogon/pokemon-showdown-client.git
synced 2026-09-30 23:01:05 -05:00
Add shift+tab function for navigation
After the introduction of the tab complete feature, the tab key can no longer be used to navigate away from the chatbox. This commit adds a shift+tab function to navigate away from the chatbox, rather than tab completing a name.
This commit is contained in:
16
js/sim.js
16
js/sim.js
@@ -1229,13 +1229,13 @@ function Lobby(id, elem) {
|
||||
// Mark a user as active for the purpose of tab complete.
|
||||
this.markUserActive = function (userid) {
|
||||
var idx = selfR.userActivity.indexOf(userid);
|
||||
if (idx != -1) {
|
||||
if (idx !== -1) {
|
||||
selfR.userActivity.splice(idx, 1);
|
||||
}
|
||||
selfR.userActivity.push(userid);
|
||||
if (selfR.userActivity.length > 400) {
|
||||
if (selfR.userActivity.length > 100) {
|
||||
// Prune the list.
|
||||
selfR.userActivity.splice(0, 200);
|
||||
selfR.userActivity.splice(0, 20);
|
||||
}
|
||||
};
|
||||
this.add = function (log) {
|
||||
@@ -1900,9 +1900,11 @@ function Lobby(id, elem) {
|
||||
this.formKeyDown = function (e) {
|
||||
hideTooltip();
|
||||
// We only handle the tab key.
|
||||
if (e.keyCode !== 9) return true;
|
||||
// If shift is held down, then don't tab complete, and instead navigate
|
||||
// away from the chatbox.
|
||||
if ((e.keyCode !== 9) || e.shiftKey) return true;
|
||||
|
||||
// No matter what, we don't want to tab away from this box.
|
||||
// We don't want to tab away from this box.
|
||||
e.preventDefault();
|
||||
|
||||
// Don't tab complete at the start of the text box.
|
||||
@@ -1940,8 +1942,8 @@ function Lobby(id, elem) {
|
||||
candidates.sort(function(a, b) {
|
||||
var aidx = selfR.userActivity.indexOf(a);
|
||||
var bidx = selfR.userActivity.indexOf(b);
|
||||
if (aidx != -1) {
|
||||
if (bidx != -1) {
|
||||
if (aidx !== -1) {
|
||||
if (bidx !== -1) {
|
||||
return bidx - aidx;
|
||||
}
|
||||
return -1; // a comes first
|
||||
|
||||
Reference in New Issue
Block a user