function love.mousepressed(x, y, button, istouch)
    local inBoard = false
    local canChange = false
    local dx = math.floor(cell.width / 3)
    local dy = math.floor(cell.height / 3)
    local cx = 0
    local cy = 0
    local mx = 0
    local my = 0
    local n = 0
    if x > grid.x1 and x < grid.x2 and y > grid.y1 and y < grid.y2 then
        inBoard = true
        cx = math.floor((x - grid.x1) / cell.width) + 1
        cy = math.floor((y - grid.y1) / cell.height) + 1
        mx = math.floor((x - grid[cx][cy].x1) / dx) + 1
        my = math.floor((y - grid[cx][cy].y1) / dy) + 1
        n = mx + 3 * (my - 1)
        if uiBoard[1][cy][cx] == 0 then canChange = true end
    end
    if canChange then
        if button == 1 then
            cursor.editMode = false
            uiBoard[2][cy][cx] = uiBoard[3][cy][cx]
            cursor.lastEditMode = false
        elseif button == 2 then
            cursor.editMode = true
            uiBoard[3][cy][cx] = uiBoard[2][cy][cx]
            uiBoard[2][cy][cx] = 0
            -- if cursor.x == cx and cursor.y == cy and cursor.lastEditMode then
            --     smallNumbersVal[cx][cy][n] = not smallNumbersVal[cx][cy][n]
            -- end
            cursor.lastEditMode = true
        end
        cursor.x = cx
        cursor.y = cy
    end
end