small fixes

This commit is contained in:
MihailRis 2024-05-18 16:57:04 +03:00
parent d3c9911640
commit 535c7d8326
4 changed files with 5 additions and 5 deletions

View File

@ -51,7 +51,7 @@ console.add_command(
) )
console.add_command( console.add_command(
"obj.tp obj:sel=$obj.id x:num~pos.x y:num~pos.y z:num~pos.z", "tp obj:sel=$obj.id x:num~pos.x y:num~pos.y z:num~pos.z",
"Teleport object", "Teleport object",
function (args, kwargs) function (args, kwargs)
player.set_pos(unpack(args)) player.set_pos(unpack(args))

View File

@ -369,7 +369,7 @@ void TextBox::click(GUI*, int x, int y) {
} }
void TextBox::mouseMove(GUI*, int x, int y) { void TextBox::mouseMove(GUI*, int x, int y) {
ssize_t index = calcIndexAt(x, y); ptrdiff_t index = calcIndexAt(x, y);
setCaret(index); setCaret(index);
extendSelection(index); extendSelection(index);
resetMaxLocalCaret(); resetMaxLocalCaret();
@ -656,7 +656,7 @@ void TextBox::setCaret(size_t position) {
} }
} }
void TextBox::setCaret(ssize_t position) { void TextBox::setCaret(ptrdiff_t position) {
if (position < 0) { if (position < 0) {
setCaret(static_cast<size_t>(input.length() + position + 1)); setCaret(static_cast<size_t>(input.length() + position + 1));
} else { } else {

View File

@ -120,7 +120,7 @@ namespace gui {
/// @brief Set caret position in the text /// @brief Set caret position in the text
/// @param position integer in range [-text.length(), text.length()] /// @param position integer in range [-text.length(), text.length()]
virtual void setCaret(ssize_t position); virtual void setCaret(ptrdiff_t position);
/// @brief Select part of the text /// @brief Select part of the text
/// @param start index of the first selected character /// @param start index of the first selected character

View File

@ -363,7 +363,7 @@ static void p_set_text(UINode* node, int idx) {
} }
static void p_set_caret(UINode* node, int idx) { static void p_set_caret(UINode* node, int idx) {
if (auto box = dynamic_cast<TextBox*>(node)) { if (auto box = dynamic_cast<TextBox*>(node)) {
box->setCaret(static_cast<ssize_t>(state->tointeger(idx))); box->setCaret(static_cast<ptrdiff_t>(state->tointeger(idx)));
} }
} }
static void p_set_editable(UINode* node, int idx) { static void p_set_editable(UINode* node, int idx) {