mirror of https://github.com/kivy/kivy.git
Window.softinput_mode fix for "pan" and "below_target" modes when using kivy virtual keyboard. (#7726)
* Softinput_mode fix for pan and below target modes Fixes issues related to correct Kivy virtual keyboard display for soft_input modes: `pan` and `bellow_target` * Refactoring * Removal of unreachable code. * refactoring and fixes * pep8
This commit is contained in:
parent
31308184cf
commit
991ae22ec6
|
@ -629,12 +629,30 @@ class WindowBase(EventDispatcher):
|
|||
import android
|
||||
return android.get_keyboard_height()
|
||||
|
||||
def _get_kivy_vkheight(self):
|
||||
mode = Config.get('kivy', 'keyboard_mode')
|
||||
if (
|
||||
mode in ['dock', 'systemanddock']
|
||||
and self._vkeyboard_cls is not None
|
||||
):
|
||||
for w in self.children:
|
||||
if isinstance(w, VKeyboard):
|
||||
vkeyboard_height = w.height * w.scale
|
||||
if self.softinput_mode == 'pan':
|
||||
return vkeyboard_height
|
||||
elif (
|
||||
self.softinput_mode == 'below_target'
|
||||
and w.target.y < vkeyboard_height
|
||||
):
|
||||
return vkeyboard_height - w.target.y
|
||||
return 0
|
||||
|
||||
def _get_kheight(self):
|
||||
if platform == 'android':
|
||||
return self._get_android_kheight()
|
||||
if platform == 'ios':
|
||||
elif platform == 'ios':
|
||||
return self._get_ios_kheight()
|
||||
return 0
|
||||
return self._get_kivy_vkheight()
|
||||
|
||||
keyboard_height = AliasProperty(_get_kheight, bind=('_keyboard_changed',))
|
||||
'''Returns the height of the softkeyboard/IME on mobile platforms.
|
||||
|
@ -1611,7 +1629,7 @@ class WindowBase(EventDispatcher):
|
|||
w2, h2 = w / 2., h / 2.
|
||||
r = radians(self.rotation)
|
||||
|
||||
x, y = 0, 0
|
||||
y = 0
|
||||
_h = h
|
||||
if smode == 'pan':
|
||||
y = kheight
|
||||
|
@ -1621,7 +1639,7 @@ class WindowBase(EventDispatcher):
|
|||
_h -= kheight
|
||||
|
||||
# prepare the viewport
|
||||
glViewport(x, y, w, _h)
|
||||
glViewport(0, 0, w, _h)
|
||||
|
||||
# do projection matrix
|
||||
projection_mat = Matrix()
|
||||
|
@ -1633,7 +1651,7 @@ class WindowBase(EventDispatcher):
|
|||
modelview_mat = modelview_mat.multiply(Matrix().rotate(r, 0, 0, 1))
|
||||
|
||||
w, h = self.size
|
||||
w2, h2 = w / 2., h / 2.
|
||||
w2, h2 = w / 2., h / 2. - y
|
||||
modelview_mat = modelview_mat.multiply(Matrix().translate(-w2, -h2, 0))
|
||||
self.render_context['modelview_mat'] = modelview_mat
|
||||
frag_modelview_mat = Matrix()
|
||||
|
@ -2132,6 +2150,12 @@ class WindowBase(EventDispatcher):
|
|||
keyboard.widget.docked = self.docked_vkeyboard
|
||||
keyboard.widget.setup_mode()
|
||||
|
||||
# sets vkeyboard position according to Window.softinput_mode
|
||||
if self.softinput_mode == 'pan':
|
||||
keyboard.widget.top = 0
|
||||
elif self.softinput_mode == 'below_target':
|
||||
keyboard.widget.top = keyboard.target.y
|
||||
|
||||
else:
|
||||
# system keyboard, just register the callback.
|
||||
keyboard = self._system_keyboard
|
||||
|
|
|
@ -406,7 +406,7 @@ class MotionEvent(MotionEventBase):
|
|||
self.pz = self.psz * z_max
|
||||
if smode:
|
||||
# Adjust y for keyboard height
|
||||
if smode == 'pan':
|
||||
if smode == 'pan' or smode == 'below_target':
|
||||
self.y -= kheight
|
||||
self.oy -= kheight
|
||||
self.py -= kheight
|
||||
|
|
Loading…
Reference in New Issue