On-screen keyboard support!

This commit is contained in:
TheBrokenRail
2023-11-02 16:38:22 -04:00
committed by iProgramInCpp
parent 0559f66102
commit f9b07014d2
10 changed files with 78 additions and 13 deletions

View File

@@ -179,11 +179,24 @@ void TextInputBox::tick()
}
}
void TextInputBox::setFocused(bool b)
void TextInputBox::setFocused(Minecraft* minecraft, bool b)
{
if (m_bFocused == b)
return;
if (b)
{
int x = m_xPos / Gui::InvGuiScale;
int y = m_yPos / Gui::InvGuiScale;
int w = m_width / Gui::InvGuiScale;
int h = m_height / Gui::InvGuiScale;
minecraft->platform()->showKeyboard(x, y, w, h);
}
else
{
minecraft->platform()->hideKeyboard();
}
m_bFocused = b;
if (b)
{
@@ -198,9 +211,9 @@ void TextInputBox::setFocused(bool b)
// - we may be undoing the work of another text box
}
void TextInputBox::onClick(int x, int y)
void TextInputBox::onClick(Minecraft* minecraft, int x, int y)
{
setFocused(clicked(x, y));
setFocused(minecraft, clicked(x, y));
}
void TextInputBox::charPressed(int k)