summaryrefslogtreecommitdiff
path: root/SOURCE/Viewer_vesy/KeyBoard.pde
blob: e8b97003716f0ab19b72e5d6f70fe51c4b6fea41 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//*****************************************************
//  Работа с клавиатурой

void keyReleased() {
  if (key > 31 && key < 127 || key > 1039 && key < 1104) {      // ввод данных
    if (selectDataEdit != 0) {
      if (inputData.length() < 30) {
        inputData += key;
      }
    }
    reset();
  }

  if (key == 8) {      //  backspase
    if (inputData.length() >= 1) {
      inputData = inputData.substring(0, inputData.length() - 1);
    }
    reset();
  }

  if (key == 127) {    //  стереть все
    inputData = "";
    reset();
  }

  if (key == 13 || key == 10) {      //  enter или return

    int hCode = table.getInt(index-1, 0);
    int hCode1 = table.getInt(index-1, 9) * 2 + table.getInt(index-1, 10) * 2 +
      table.getInt(index-1, 12) * 2 + table.getInt(index-1, 13) * 2 +
      table.getInt(index-1, 14) * 2 + table.getInt(index-1, 15) * 2;
    table.setInt(index-1, 0, hCode);

    if (selectDataEdit == 1) {
      table.setInt(index-1, selectDataEdit - 1, int(inputData.trim()));
    } else if (selectDataEdit == 14 || selectDataEdit == 15) {
      table.setInt(index-1, selectDataEdit, int(inputData.trim()));
    } else {
      table.setString(index-1, selectDataEdit, inputData.trim());
    }

    if (hCode == hCode1) {
      hCode1 = table.getInt(index-1, 9) * 2 + table.getInt(index-1, 10) * 2 +
        table.getInt(index-1, 12)*2 +
        table.getInt(index-1, 13)*2 + table.getInt(index-1, 14)*2 +
        table.getInt(index-1, 15)*2;
      table.setInt(index-1, 0, hCode1);
    }

    //saveTable(table, filePath1 + "base.csv");
    saveTable(table, filePath + "base.csv");

    selectDataEdit = 0;
    reset();
    inputData = "";
  }
  key = 0;
}