Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
TooTallNate committed Oct 31, 2023
1 parent ff0033a commit 2b9ce79
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions apps/virtual-keyboard/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ const ctx = Switch.screen.getContext('2d');
const vk = navigator.virtualKeyboard;

function render() {
const isOpen = vk.boundingRect.height > 0;

ctx.fillStyle = 'white';
ctx.fillRect(0, 0, canvas.width, canvas.height);

Expand All @@ -15,12 +17,14 @@ function render() {
ctx.fillText('Press "ZR" to show text keyboard', 10, 68);

ctx.font = '32px system-ui';
ctx.fillStyle = 'black';
ctx.fillStyle = isOpen ? 'black' : '#550';
ctx.fillText(`${vk.value}`, 10, 120);

const { width } = ctx.measureText(vk.value.slice(0, vk.cursorIndex));
ctx.fillStyle = 'green';
ctx.fillRect(13 + width, 90, 3, 32);
if (isOpen) {
const { width } = ctx.measureText(vk.value.slice(0, vk.cursorIndex));
ctx.fillStyle = 'green';
ctx.fillRect(13 + width, 90, 3, 32);
}
}

Switch.addEventListener('buttondown', (e) => {
Expand Down

0 comments on commit 2b9ce79

Please sign in to comment.