Skip to content
Snippets Groups Projects
Commit 237f7847 authored by Silas Dohm's avatar Silas Dohm
Browse files

added basic mouse support

parent 9569a799
Branches
No related tags found
No related merge requests found
......@@ -31,7 +31,7 @@ class Cell {
this.word[0].highlight();
if (this.word[1])
this.word[1].highlight();
this.drawChar('#7e5df9');
this.drawChar(m_orientation?'#7e5df9':'#80C4E4');
}
clearHighlight = function () {
if (this.word[0])
......@@ -45,7 +45,6 @@ class Word {
static across = document.getElementById("across");
static down = document.getElementById("down");
constructor(clue, word, x, y, direction) {
this.hint = mycell[x][y];
this.chars = new Array();
this.li = document.createElement("li");
this.highlightColor = direction? '#c8b9fc':"#CFE9F5";
......@@ -133,8 +132,6 @@ function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function click(x, y) {
}
document.addEventListener('keydown', logKey);
function logKey(e) {
lastCell = activeCell;
......@@ -219,7 +216,19 @@ function logKey(e) {
lastCell.clearHighlight();
activeCell.highlight();
}
a_canvas.addEventListener('mousedown',function (e) { //mouse navigation
let x =Math.floor(e.offsetX/(a_canvas.clientWidth/columns));
let y =Math.floor(e.offsetY/(a_canvas.clientHeight/rows));
if(mycell[x][y].actualChar != ""){
lastCell = activeCell;
activeCell = mycell[x][y]
if(activeCell == lastCell)
m_orientation = !m_orientation;
activeMode = mode.insert;
lastCell.clearHighlight();
activeCell.highlight();
}
});
function initNeighbours() {
for (i = 0; i < columns; i++) { //precompute neighbours
for (j = 0; j < rows; j++) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment