Android Soft Keyboard is over the Input text

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
derekbaker90
Prole
Posts: 2
Joined: Fri Nov 06, 2020 10:41 pm

Android Soft Keyboard is over the Input text

Post by derekbaker90 »

I'm using https://github.com/love2d/love-android to export my game to Android. I'm using love.keyboard.setTextInput with all the parameters correctly applied (I draw a rectangle with love.graphics.rectangle to know that the input text area is the same as my input text). As I understand, this method tells android and iOS where my input is, so the OS keyboard won't be shown over the input. The case is that the keyboard is being shown over the input. I already tried setting android:windowSoftInputMode activity property to "adjustResize" and to "adjustPane" and it didn't work either
I'm using the push library to adjust the screen size to the device screen and the suit library to create the text input element. I'm also using a font in assets/fonts/bit5x5.ttf

main.lua

Code: Select all

push = require 'vendor/push'
suit = require 'vendor/suit'

love.window.setMode(0, 0, {
    fullscreen = true,
    vsync = -1
  })
WINDOW_WIDTH, WINDOW_HEIGHT = love.graphics.getDimensions()

VIRTUAL_WIDTH = 432
VIRTUAL_HEIGHT = 243

titleFont = love.graphics.newFont('assets/fonts/bit5x5.ttf', 32)
subtitleFont = love.graphics.newFont('assets/fonts/bit5x5.ttf', 16)
btnFont = love.graphics.newFont('assets/fonts/bit5x5.ttf', 8)

local input = {text = ""}

function love.load()
    math.randomseed(os.time())
    love.window.setTitle('Pong Rush')
    love.graphics.setDefaultFilter('nearest', 'nearest')
  
    push:setupScreen(VIRTUAL_WIDTH, VIRTUAL_HEIGHT, WINDOW_WIDTH, WINDOW_HEIGHT, {
      fullscreen = false,
      resizable = false,
      highdpi = true
    })
end

function love.draw()
  push:apply('start')
    love.graphics.clear(40/255, 45/255, 52/255, 1)
  
    love.graphics.setFont(titleFont)
    love.graphics.printf('Pong Rush!', 0, 20, VIRTUAL_WIDTH, 'center')
  
    love.graphics.setFont(subtitleFont)
    love.graphics.printf('Multiplayer/Create', 0, 60, VIRTUAL_WIDTH, 'center')
  
    suit.draw()
  push:apply('end')
end

function love.update(dt)
  local x, y = push:toGame(love.mouse.getPosition())
  suit.updateMouse(x or 0, y or VIRTUAL_HEIGHT)

  if input.text:len() > 25 then
    input.text = string.sub(input.text, 1, 25);
  end
  love.graphics.setFont(btnFont)
  suit.layout:reset(math.floor(VIRTUAL_WIDTH/2 - 100), math.floor(VIRTUAL_HEIGHT/2))
  suit.layout:padding(10)
  if suit.Input(input, suit.layout:row(200,20)).hit then
    -- set the input box so the device will know where it is to not cover it with the soft keyboard
    love.keyboard.setTextInput(true, math.floor(VIRTUAL_WIDTH/2 - 100), math.floor(VIRTUAL_HEIGHT/2), 200, 20)
  end
end

function love.textedited(text, start, length)
  -- for IME input
  suit.textedited(text, start, length)
end

function love.textinput(t)
-- forward text input to SUIT
suit.textinput(t)
end

function love.keypressed(key)
-- forward keypresses to SUIT
suit.keypressed(key)
end
conf.lua

Code: Select all

function love.conf(t)
  t.window.wdth = 1280
  t.window.height = 720
  t.modules.joystick = false
  t.externalstorage = true
end
AndroidManifest.xml

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<manifest package="org.love2d.android.executable"
  android:installLocation="auto" xmlns:android="http://schemas.android.com/apk/res/android">
  <uses-permission android:name="android.permission.INTERNET" />
  <uses-permission android:name="android.permission.VIBRATE" />
  <uses-permission android:name="android.permission.BLUETOOTH" />
  <uses-permission android:name="android.permission.RECORD_AUDIO" />
  <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="23" />
  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="28" />

  <!-- OpenGL ES 2.0 -->
  <uses-feature android:glEsVersion="0x00020000" />
  <!-- Touchscreen support -->
  <uses-feature android:name="android.hardware.touchscreen" android:required="false" />
  <!-- Game controller support -->
  <uses-feature android:name="android.hardware.bluetooth" android:required="false" />
  <uses-feature android:name="android.hardware.gamepad" android:required="false" />
  <uses-feature android:name="android.hardware.usb.host" android:required="false" />
  <!-- External mouse input events -->
  <uses-feature android:name="android.hardware.type.pc" android:required="false" />

  <application
      android:allowBackup="true"
      android:icon="@drawable/love"
      android:label="Pong Rush"
      android:usesCleartextTraffic="true"
      android:hardwareAccelerated="true" >
      <service android:name="org.love2d.android.DownloadService" />
      <activity
        android:name="org.love2d.android.GameActivity"
        android:configChanges="orientation|screenSize|smallestScreenSize|screenLayout|keyboard|keyboardHidden|navigation"
        android:label="Pong Rush"
        android:launchMode="singleTask"
        android:screenOrientation="landscape"
        android:resizeableActivity="true"
        android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
        <intent-filter>
          <action android:name="android.intent.action.MAIN" />
          <category android:name="android.intent.category.LAUNCHER" />
          <category android:name="tv.ouya.intent.category.GAME" />
        </intent-filter>
        <intent-filter>
          <action android:name="android.intent.action.VIEW" />
          <category android:name="android.intent.category.DEFAULT" />
          <category android:name="android.intent.category.BROWSABLE" />
          <data android:scheme="file" />
          <data android:mimeType="*/*" />
          <data android:pathPattern=".*\\.love" />
          <data android:host="*" />
        </intent-filter>
        <intent-filter>
          <action android:name="android.intent.action.VIEW" />
          <category android:name="android.intent.category.DEFAULT" />
          <category android:name="android.intent.category.BROWSABLE" />
          <data android:scheme="content" />
          <data android:mimeType="application/x-love-game" />
        </intent-filter>
        <intent-filter>
          <action android:name="android.intent.action.VIEW" />
          <category android:name="android.intent.category.DEFAULT" />
          <category android:name="android.intent.category.BROWSABLE" />
          <data android:scheme="content" />
          <data android:mimeType="application/octet-stream" />
        </intent-filter>
        <intent-filter>
          <action android:name="android.intent.action.SEND" />
          <category android:name="android.intent.category.DEFAULT" />
          <data android:mimeType="application/*" />
        </intent-filter>
      </activity>
      <activity
        android:name="org.love2d.android.DownloadActivity"
        android:noHistory="true"
        android:theme="@android:style/Theme.NoTitleBar" >
        <intent-filter>
          <action android:name="android.intent.action.VIEW" />
          <category android:name="android.intent.category.DEFAULT" />
          <category android:name="android.intent.category.BROWSABLE" />
          <data android:scheme="http"
            android:host="*"
            android:mimeType="*/*"
            android:pathPattern=".*\\.love" />
          <data android:scheme="https"
            android:host="*"
            android:mimeType="*/*"
            android:pathPattern=".*\\.love" />
        </intent-filter>
      </activity>
    </application>
</manifest>
This is the app running in my Android phone (Google Pixel XL):
Image

With an outline rectangle to know that the position and size are correct adding a

Code: Select all

love.graphics.rectangle("line", math.floor(VIRTUAL_WIDTH/2 - 100), math.floor(VIRTUAL_HEIGHT/2), 200, 20)
:
Image

And the final unwanted result (the soft keyboard covering the input when I select it to write):
Image
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 6 guests