Add screen keyboard handling for iOS
This commit is contained in:
parent
05a75dcbce
commit
784d641ebc
@ -318,6 +318,7 @@ namespace irr
|
||||
virtual s32 getBottomPadding() { return 0; }
|
||||
virtual s32 getLeftPadding() { return 0; }
|
||||
virtual s32 getRightPadding() { return 0; }
|
||||
virtual f32 getNativeScale() const { return 1.0f; }
|
||||
virtual void setWindowMinimumSize(u32 width, u32 height) {}
|
||||
virtual bool isResizable() const { return false; }
|
||||
//! Check if a driver type is supported by the engine.
|
||||
|
@ -950,6 +950,22 @@ bool CIrrDeviceSDL::supportsTouchDevice() const
|
||||
return SDL_GetNumTouchDevices() > 0;
|
||||
}
|
||||
|
||||
|
||||
bool CIrrDeviceSDL::hasOnScreenKeyboard() const
|
||||
{
|
||||
return SDL_HasScreenKeyboardSupport() == SDL_TRUE;
|
||||
}
|
||||
|
||||
|
||||
bool CIrrDeviceSDL::hasHardwareKeyboard() const
|
||||
{
|
||||
#ifdef MOBILE_STK
|
||||
return SDL_HasHardwareKeyboardConnected() == SDL_TRUE;
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
} // end namespace irr
|
||||
|
||||
#endif // _IRR_COMPILE_WITH_SDL_DEVICE_
|
||||
|
@ -133,6 +133,12 @@ namespace irr
|
||||
return RightPadding * NativeScale;
|
||||
}
|
||||
|
||||
virtual f32 getNativeScale() const { return NativeScale; }
|
||||
|
||||
virtual bool hasOnScreenKeyboard() const;
|
||||
|
||||
virtual bool hasHardwareKeyboard() const;
|
||||
|
||||
//! Implementation of the linux cursor control
|
||||
class CCursorControl : public gui::ICursorControl
|
||||
{
|
||||
|
@ -273,9 +273,12 @@ CGUIEditBox::~CGUIEditBox()
|
||||
SDL_StopTextInput();
|
||||
g_editbox = NULL;
|
||||
#endif
|
||||
|
||||
#ifdef ANDROID
|
||||
if (GUIEngine::ScreenKeyboard::shouldUseScreenKeyboard() &&
|
||||
GUIEngine::ScreenKeyboard::hasSystemScreenKeyboard())
|
||||
irr_driver->getDevice()->toggleOnScreenKeyboard(false);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
}
|
||||
@ -686,9 +689,11 @@ bool CGUIEditBox::processKey(const SEvent& event)
|
||||
break;
|
||||
case IRR_KEY_RETURN:
|
||||
{
|
||||
#ifdef ANDROID
|
||||
if (GUIEngine::ScreenKeyboard::shouldUseScreenKeyboard() &&
|
||||
GUIEngine::ScreenKeyboard::hasSystemScreenKeyboard())
|
||||
irr_driver->getDevice()->toggleOnScreenKeyboard(false);
|
||||
#endif
|
||||
sendGuiEvent( EGET_EDITBOX_ENTER );
|
||||
}
|
||||
break;
|
||||
@ -1156,9 +1161,11 @@ bool CGUIEditBox::processMouse(const SEvent& event)
|
||||
|
||||
if (GUIEngine::ScreenKeyboard::shouldUseScreenKeyboard())
|
||||
{
|
||||
#ifdef ANDROID
|
||||
if (GUIEngine::ScreenKeyboard::hasSystemScreenKeyboard())
|
||||
irr_driver->getDevice()->toggleOnScreenKeyboard(true, m_type);
|
||||
else
|
||||
#endif
|
||||
openScreenKeyboard();
|
||||
}
|
||||
|
||||
@ -1382,6 +1389,13 @@ void CGUIEditBox::calculateScrollPos()
|
||||
rect.w = 1;
|
||||
rect.h =
|
||||
CurrentTextRect.LowerRightCorner.Y - CurrentTextRect.UpperLeftCorner.Y;
|
||||
float inverse_scale = 1.0f;
|
||||
if (irr_driver->getDevice()->getNativeScale() > 0.0f)
|
||||
inverse_scale = 1.0f / irr_driver->getDevice()->getNativeScale();
|
||||
rect.x *= inverse_scale;
|
||||
rect.y *= inverse_scale;
|
||||
rect.w *= inverse_scale;
|
||||
rect.h *= inverse_scale;
|
||||
SDL_SetTextInputRect(&rect);
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user