Start maybe working on a native app
This commit is contained in:
@@ -5,6 +5,7 @@ import { point_inside_rec } from "@/common/utils.ts";
|
||||
import { InputManager, type KeyCode } from "@/client/input_manager.ts";
|
||||
import { draw_rect, draw_rect_stroke, draw_text, measure_text } from "@/client/renderer/mod.ts";
|
||||
import { draw_gui_sprite } from "./gui_sprites.ts";
|
||||
import { platform } from "@/client/platform.ts";
|
||||
|
||||
export const TEXT_SCALE = 2;
|
||||
// how tall the font is at scale 1
|
||||
@@ -124,14 +125,14 @@ export class TextInput {
|
||||
const copy = InputManager.is_shortcut_pressed("c");
|
||||
const cut = InputManager.is_shortcut_pressed("x");
|
||||
if ((copy || cut) && this.anchor !== this.caret) {
|
||||
navigator.clipboard?.writeText(this.selected_text()).catch(() => {});
|
||||
platform.write_clipboard(this.selected_text()).catch(() => {});
|
||||
if (cut) {
|
||||
this.delete_to(this.caret);
|
||||
}
|
||||
}
|
||||
if (InputManager.is_shortcut_pressed("v")) {
|
||||
// the browser may ask first, it's put in once it answers
|
||||
navigator.clipboard?.readText().then((text) => this.insert(text), () => {});
|
||||
platform.read_clipboard().then((text) => this.insert(text), () => {});
|
||||
}
|
||||
for (const char of InputManager.get_typed_characters()) {
|
||||
this.insert(char);
|
||||
|
||||
Reference in New Issue
Block a user