Constructor
new KeyGrid(keygrid_canvas, target_layout)
- Source:
Properties:
| Name | Type | Description |
|---|---|---|
x_positions |
Array.<Array.<Array.<number>>> | A 3D array defining the start and end x positions (in pixels) of each keygrid box. The first two dimensions specify the row and column index of the keygrid box. The third dimension specifies the start and end x coordinates of the box. For example:
[
[[x00_start, x00_stop], [x01_start, x01_end], ... ],
[[x10_start, x10_end], [x11_start, x11_end], ... ],
...
]
|
y_positions |
Array.<Array.<Array.<number>>> | A 3D array defining the start and end y positions (in pixels) of each keygrid box. The first two dimensions specify the row and column index of the keygrid box. The third dimension specifies the start and end y coordinates of the box. For example:
[
[[y00_start, y00_stop], [y01_start, y01_end], ... ],
[[y10_start, y10_end], [y11_start, y11_end], ... ],
...
]
|
in_pause |
boolean | Whether the keygrid is in pause following a user selection and should be highlighted in green. |
Parameters:
| Name | Type | Description |
|---|---|---|
keygrid_canvas |
KeyboardCanvas | The KeyboardCanvas instance used to draw the keygrid |
target_layout |
Array.<Array.<String>> | A 2D array specifying the relative locations of the keyboard keys. |
Methods
draw_layout()
- Description:
Draws the bounding rectangles for the currently calculated keygrid layout.
- Source:
generate_layout()
- Description:
Calculates the pixel positions for the bounding rectangles in the keygrid. Needs to be recalled on any window resizing event.
- Source:
highlight_square(row, col)
- Description:
Highlights the rectangle of the keygrid specified by the given row and column
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
row |
number | the row index in the keygrid of the rectangle to highlight |
col |
number | the column index in the keygrid of the rectangle to highlight |