def get_keyboard_frame(self):
'''get corrected keyboard frame, in the screen coordinates.
built in function breaks when in fullscreen, as it reports kbframe relative to a landscape screen'''
#TODO: remove dependence on webview, use xaxis/yaxis to determine rotation instead
origin=ui.convert_point((0,0),None,self )
xaxis=ui.convert_point((1,0),None,self )
xaxis=[xaxis[j]-origin[j] for j in (0,1)]
yaxis=ui.convert_point((0,1),None,self )
yaxis=[yaxis[j]-origin[j] for j in (0,1)]
o=self.__w.eval_js('window.orientation')
frame=ui.get_keyboard_frame()
(w,h)=ui.get_screen_size()
if xaxis[0]==1 and yaxis[1]==1 and frame[0]==0:
#we are not in fullscreen, just return kbframe
fixedframe=frame
elif o=='0':
fixedframe= frame #ok
elif o=='-90':
fixedframe= [frame[1], frame[0], h,frame[2]]
elif o=='180':
fixedframe= [frame[0], h-frame[1]-frame[3], frame[2],frame[3]] #okrqq
elif o=='90':
fixedframe= [frame[1], w-frame[0]-frame[2],h,frame[2]]
else:
raise Error('UnexpectedOrientation')
return fixedframe
fixed_convert_and_kbframe.py 文件源码
python
阅读 24
收藏 0
点赞 0
评论 0
评论列表
文章目录