Improve chat input

This commit is contained in:
2026-09-27 12:54:10 -03:00
parent 60188ff735
commit d822267bd3
6 changed files with 288 additions and 33 deletions
+6
View File
@@ -147,6 +147,9 @@ export class ModGraphics implements Graphics {
this.#inputs.set(id, input);
}
const hovered = point_inside_rec(this.mouse.x, this.mouse.y, x, y, w, INPUT_HEIGHT);
if (this.#focused === id || (hovered && this.mouse.pressed)) {
input.handle_mouse({ x, y, width: w, height: INPUT_HEIGHT }, x + 6);
}
if (this.mouse.pressed) {
if (hovered) {
this.#focused = id;
@@ -167,6 +170,9 @@ export class ModGraphics implements Graphics {
draw_rect(x, y, w, INPUT_HEIGHT, focused ? WHITE : GREY);
draw_rect(x + 2, y + 2, w - 4, INPUT_HEIGHT - 4, [0, 0, 0, 1]);
this.clip(x + 2, y + 2, w - 4, INPUT_HEIGHT - 4, () => {
if (focused) {
input.draw_selection(x + 6, y + 6, INPUT_HEIGHT - 12);
}
draw_text(input.value, x + 6, y + 4, TEXT_SCALE, WHITE);
if (focused && TextInput.caret_visible()) {
draw_rect(input.caret_x(x + 6), y + 6, 2, INPUT_HEIGHT - 12, WHITE);