Skip to content
This repository has been archived by the owner on Mar 28, 2024. It is now read-only.

Commit

Permalink
fix(hot key bug fix): range bug when formula move selection
Browse files Browse the repository at this point in the history
  • Loading branch information
DR-Univer committed Sep 24, 2020
1 parent 5109873 commit f4625d1
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions src/controllers/keyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,25 @@ import Store from '../store';

let luckysheet_shiftkeydown = false;

function formulaMoveEvent(dir, ctrlKey, shiftKey){
if ($("#luckysheet-formula-search-c").is(":visible")) {
let $up = $("#luckysheet-formula-search-c").find(".luckysheet-formula-search-item-active").next();
if ($up.length == 0) {
$up = $("#luckysheet-formula-search-c").find(".luckysheet-formula-search-item").first();
function formulaMoveEvent(dir, ctrlKey, shiftKey, event){
if ($("#luckysheet-formula-search-c").is(":visible") && (dir=="up" || dir=="down") ) {
let $obj;
if(dir=="down"){
$obj = $("#luckysheet-formula-search-c").find(".luckysheet-formula-search-item-active").next();
if ($obj.length == 0) {
$obj = $("#luckysheet-formula-search-c").find(".luckysheet-formula-search-item").first();
}
}
else if(dir=="up"){
$obj = $("#luckysheet-formula-search-c").find(".luckysheet-formula-search-item-active").prev();
if ($obj.length == 0) {
$obj = $("#luckysheet-formula-search-c").find(".luckysheet-formula-search-item").last();
}
}


$("#luckysheet-formula-search-c").find(".luckysheet-formula-search-item").removeClass("luckysheet-formula-search-item-active");
$up.addClass("luckysheet-formula-search-item-active");
$obj.addClass("luckysheet-formula-search-item-active");

event.preventDefault();
}
Expand Down Expand Up @@ -77,6 +87,7 @@ function formulaMoveEvent(dir, ctrlKey, shiftKey){

luckysheetMoveHighlightCell(dir_n, step, "rangeOfFormula");
}
event.preventDefault();
}
else if(formula.israngeseleciton()){
let anchor = $(window.getSelection().anchorNode);
Expand Down Expand Up @@ -151,6 +162,7 @@ function formulaMoveEvent(dir, ctrlKey, shiftKey){
luckysheetMoveHighlightCell(dir_n, step, "rangeOfFormula");
}
}
event.preventDefault();
}
else if(!ctrlKey && !shiftKey){
let anchor = $(window.getSelection().anchorNode);
Expand Down Expand Up @@ -832,16 +844,16 @@ export function keyboardInitial(){
event.preventDefault();
}
else if (kcode == keycode.UP && parseInt($inputbox.css("top")) > 0) {
formulaMoveEvent("up", ctrlKey, shiftKey);
formulaMoveEvent("up", ctrlKey, shiftKey,event);
}
else if (kcode == keycode.DOWN && parseInt($inputbox.css("top")) > 0) {
formulaMoveEvent("down", ctrlKey, shiftKey);
formulaMoveEvent("down", ctrlKey, shiftKey,event);
}
else if (kcode == keycode.LEFT && parseInt($inputbox.css("top")) > 0) {
formulaMoveEvent("left", ctrlKey, shiftKey);
formulaMoveEvent("left", ctrlKey, shiftKey,event);
}
else if (kcode == keycode.RIGHT && parseInt($inputbox.css("top")) > 0) {
formulaMoveEvent("right", ctrlKey, shiftKey);
formulaMoveEvent("right", ctrlKey, shiftKey,event);
}
else if (!((kcode >= 112 && kcode <= 123) || kcode <= 46 || kcode == 144 || kcode == 108 || event.ctrlKey || event.altKey || (event.shiftKey && (kcode == 37 || kcode == 38 || kcode == 39 || kcode == 40 || kcode == keycode.WIN || kcode == keycode.WIN_R || kcode == keycode.MENU))) || kcode == 8 || kcode == 32 || kcode == 46 || (event.ctrlKey && kcode == 86)) {
formula.functionInputHanddler($("#luckysheet-functionbox-cell"), $("#luckysheet-rich-text-editor"), kcode);
Expand Down

0 comments on commit f4625d1

Please sign in to comment.