@@ -629,12 +629,30 @@ def _get_android_kheight(self):
629
629
import android
630
630
return android .get_keyboard_height ()
631
631
632
+ def _get_kivy_vkheight (self ):
633
+ mode = Config .get ('kivy' , 'keyboard_mode' )
634
+ if (
635
+ mode in ['dock' , 'systemanddock' ]
636
+ and self ._vkeyboard_cls is not None
637
+ ):
638
+ for w in self .children :
639
+ if isinstance (w , VKeyboard ):
640
+ vkeyboard_height = w .height * w .scale
641
+ if self .softinput_mode == 'pan' :
642
+ return vkeyboard_height
643
+ elif (
644
+ self .softinput_mode == 'below_target'
645
+ and w .target .y < vkeyboard_height
646
+ ):
647
+ return vkeyboard_height - w .target .y
648
+ return 0
649
+
632
650
def _get_kheight (self ):
633
651
if platform == 'android' :
634
652
return self ._get_android_kheight ()
635
- if platform == 'ios' :
653
+ elif platform == 'ios' :
636
654
return self ._get_ios_kheight ()
637
- return 0
655
+ return self . _get_kivy_vkheight ()
638
656
639
657
keyboard_height = AliasProperty (_get_kheight , bind = ('_keyboard_changed' ,))
640
658
'''Returns the height of the softkeyboard/IME on mobile platforms.
@@ -1611,7 +1629,7 @@ def update_viewport(self):
1611
1629
w2 , h2 = w / 2. , h / 2.
1612
1630
r = radians (self .rotation )
1613
1631
1614
- x , y = 0 , 0
1632
+ y = 0
1615
1633
_h = h
1616
1634
if smode == 'pan' :
1617
1635
y = kheight
@@ -1621,7 +1639,7 @@ def update_viewport(self):
1621
1639
_h -= kheight
1622
1640
1623
1641
# prepare the viewport
1624
- glViewport (x , y , w , _h )
1642
+ glViewport (0 , 0 , w , _h )
1625
1643
1626
1644
# do projection matrix
1627
1645
projection_mat = Matrix ()
@@ -1633,7 +1651,7 @@ def update_viewport(self):
1633
1651
modelview_mat = modelview_mat .multiply (Matrix ().rotate (r , 0 , 0 , 1 ))
1634
1652
1635
1653
w , h = self .size
1636
- w2 , h2 = w / 2. , h / 2.
1654
+ w2 , h2 = w / 2. , h / 2. - y
1637
1655
modelview_mat = modelview_mat .multiply (Matrix ().translate (- w2 , - h2 , 0 ))
1638
1656
self .render_context ['modelview_mat' ] = modelview_mat
1639
1657
frag_modelview_mat = Matrix ()
@@ -2132,6 +2150,12 @@ def request_keyboard(
2132
2150
keyboard .widget .docked = self .docked_vkeyboard
2133
2151
keyboard .widget .setup_mode ()
2134
2152
2153
+ # sets vkeyboard position according to Window.softinput_mode
2154
+ if self .softinput_mode == 'pan' :
2155
+ keyboard .widget .top = 0
2156
+ elif self .softinput_mode == 'below_target' :
2157
+ keyboard .widget .top = keyboard .target .y
2158
+
2135
2159
else :
2136
2160
# system keyboard, just register the callback.
2137
2161
keyboard = self ._system_keyboard
0 commit comments