mirror of
https://github.com/love2d/love.git
synced 2026-08-18 03:34:23 +02:00
Added a love.keyboard.setTextInput variant (setTextInput(enable, x, y, width, height)) to specify a rectangle where text is expected to be displayed on the screen. This is used as a hint so on-screen keyboards won't cover the text area.
Added love.keyboard.hasScreenKeyboard. --HG-- branch : minor
This commit is contained in:
@@ -117,11 +117,26 @@ void Keyboard::setTextInput(bool enable)
|
||||
SDL_StopTextInput();
|
||||
}
|
||||
|
||||
void Keyboard::setTextInput(bool enable, int x, int y, int w, int h)
|
||||
{
|
||||
// TODO: SetTextInputRect expects coordinates in window-space, but
|
||||
// setTextInput uses pixels. We should convert here.
|
||||
SDL_Rect rect = {x, y, w, h};
|
||||
SDL_SetTextInputRect(&rect);
|
||||
|
||||
setTextInput(enable);
|
||||
}
|
||||
|
||||
bool Keyboard::hasTextInput() const
|
||||
{
|
||||
return SDL_IsTextInputActive();
|
||||
}
|
||||
|
||||
bool Keyboard::hasScreenKeyboard() const
|
||||
{
|
||||
return SDL_HasScreenKeyboardSupport();
|
||||
}
|
||||
|
||||
bool Keyboard::getConstant(Scancode in, SDL_Scancode &out)
|
||||
{
|
||||
return scancodes.find(in, out);
|
||||
|
||||
@@ -53,7 +53,9 @@ public:
|
||||
Scancode getScancodeFromKey(Key key) const;
|
||||
|
||||
void setTextInput(bool enable);
|
||||
void setTextInput(bool enable, int x, int y, int w, int h);
|
||||
bool hasTextInput() const;
|
||||
bool hasScreenKeyboard() const;
|
||||
|
||||
static bool getConstant(Scancode in, SDL_Scancode &out);
|
||||
static bool getConstant(SDL_Scancode in, Scancode &out);
|
||||
|
||||
Reference in New Issue
Block a user