def get_keyboard_frame(self,frame=None):
'''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
if frame is None:
frame=ui.get_keyboard_frame()
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')
(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
评论列表
文章目录