mirror of
https://github.com/celisej567/mcpe.git
synced 2026-09-23 20:09:46 +03:00
AppPlatform Fixes
This commit is contained in:
committed by
iProgramInCpp
parent
2356757730
commit
06c69d3cc8
@@ -263,11 +263,12 @@ void Screen::mouseClicked(int xPos, int yPos, int d) // d = clicked?
|
||||
TextInputBox* textInput = m_textInputs[i];
|
||||
if (textInput->m_bFocused == handleFocused)
|
||||
{
|
||||
textInput->onClick(m_pMinecraft, xPos, yPos);
|
||||
textInput->onClick(xPos, yPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef USE_NATIVE_ANDROID
|
||||
// if the keyboard is shown:
|
||||
if (m_pMinecraft->platform()->getKeyboardUpOffset())
|
||||
{
|
||||
@@ -284,9 +285,10 @@ void Screen::mouseClicked(int xPos, int yPos, int d) // d = clicked?
|
||||
}
|
||||
|
||||
if (!areAnyFocused)
|
||||
m_pMinecraft->platform()->showKeyboard(false);
|
||||
m_pMinecraft->platform()->hideKeyboard();
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void Screen::mouseReleased(int xPos, int yPos, int d)
|
||||
@@ -361,6 +363,7 @@ void Screen::onRender(int mouseX, int mouseY, float f)
|
||||
|
||||
int Screen::getYOffset()
|
||||
{
|
||||
#ifdef USE_NATIVE_ANDROID
|
||||
int keybOffset = m_pMinecraft->platform()->getKeyboardUpOffset();
|
||||
if (!keybOffset)
|
||||
return 0;
|
||||
@@ -395,6 +398,9 @@ int Screen::getYOffset()
|
||||
}
|
||||
|
||||
return offset;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void Screen::updateEvents()
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "client/app/Minecraft.hpp"
|
||||
#ifndef ORIGINAL_CODE
|
||||
|
||||
#if defined(ANDROID) && !defined(USE_SDL)
|
||||
#ifdef USE_NATIVE_ANDROID
|
||||
#define HANDLE_CHARS_SEPARATELY // faked though, see platforms/android/minecraftcpp/minecraftcpp.NativeActivity/main.cpp
|
||||
#endif
|
||||
|
||||
@@ -32,6 +32,11 @@ TextInputBox::TextInputBox(Screen* parent, int id, int x, int y, int width, int
|
||||
m_pParent = parent;
|
||||
}
|
||||
|
||||
TextInputBox::~TextInputBox()
|
||||
{
|
||||
m_pParent->m_pMinecraft->platform()->hideKeyboard();
|
||||
}
|
||||
|
||||
void TextInputBox::init(Font* pFont)
|
||||
{
|
||||
m_pFont = pFont;
|
||||
@@ -179,22 +184,22 @@ void TextInputBox::tick()
|
||||
}
|
||||
}
|
||||
|
||||
void TextInputBox::setFocused(Minecraft* minecraft, bool b)
|
||||
void TextInputBox::setFocused(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);
|
||||
int x = (int) (((float) m_xPos) / Gui::InvGuiScale);
|
||||
int y = (int) (((float) m_yPos) / Gui::InvGuiScale);
|
||||
int w = (int) (((float) m_width) / Gui::InvGuiScale);
|
||||
int h = (int) (((float) m_height) / Gui::InvGuiScale);
|
||||
m_pParent->m_pMinecraft->platform()->showKeyboard(x, y, w, h);
|
||||
}
|
||||
else
|
||||
{
|
||||
minecraft->platform()->hideKeyboard();
|
||||
m_pParent->m_pMinecraft->platform()->hideKeyboard();
|
||||
}
|
||||
|
||||
m_bFocused = b;
|
||||
@@ -203,17 +208,15 @@ void TextInputBox::setFocused(Minecraft* minecraft, bool b)
|
||||
m_lastFlashed = getTimeMs();
|
||||
m_bCursorOn = true;
|
||||
m_insertHead = int(m_text.size());
|
||||
|
||||
m_pParent->m_pMinecraft->platform()->showKeyboard(true);
|
||||
}
|
||||
|
||||
// don't actually hide the keyboard when unfocusing
|
||||
// - we may be undoing the work of another text box
|
||||
}
|
||||
|
||||
void TextInputBox::onClick(Minecraft* minecraft, int x, int y)
|
||||
void TextInputBox::onClick(int x, int y)
|
||||
{
|
||||
setFocused(minecraft, clicked(x, y));
|
||||
setFocused(clicked(x, y));
|
||||
}
|
||||
|
||||
void TextInputBox::charPressed(int k)
|
||||
|
||||
@@ -23,6 +23,7 @@ class TextInputBox : public GuiComponent
|
||||
{
|
||||
public:
|
||||
TextInputBox(Screen*, int id, int x, int y, int width = 200, int height = 12, const std::string& placeholder = "", const std::string& text = "");
|
||||
~TextInputBox();
|
||||
|
||||
void init(Font* pFont);
|
||||
void setEnabled(bool bEnabled);
|
||||
@@ -30,8 +31,8 @@ public:
|
||||
void charPressed(int chr);
|
||||
void render();
|
||||
void tick();
|
||||
void setFocused(Minecraft*, bool b);
|
||||
void onClick(Minecraft*, int x, int y);
|
||||
void setFocused(bool b);
|
||||
void onClick(int x, int y);
|
||||
bool clicked(int x, int y);
|
||||
|
||||
public:
|
||||
|
||||
@@ -35,7 +35,7 @@ void ChatScreen::init()
|
||||
|
||||
// set focus directly on the chat text box
|
||||
m_textChat.init(m_pFont);
|
||||
m_textChat.setFocused(m_pMinecraft, true);
|
||||
m_textChat.setFocused(true);
|
||||
|
||||
m_buttons.push_back(&m_btnSend);
|
||||
m_textInputs.push_back(&m_textChat);
|
||||
|
||||
Reference in New Issue
Block a user