Improve chat input
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user