Esempio n. 1
0
    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
    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
Esempio n. 3
0
        def draw(self):
            '''draw a green box around kb frame, padded by 10 pixels'''
            kb=self.get_keyboard_frame()
           # print kb
            kb_self=self.convert_rect(kb,None,self)
           # print kb_self
            ui.set_color((0,1,0,0.5))
            ui.fill_rect(kb_self[0]-10,kb_self[1]-10, kb_self[2]+20,kb_self[3]+20)

            self.t3.text=('orientation {}\n'
                          'kbframe       {}\n'
                          'kbframe fixed {}\n '
                          'kbframe in V  {}\n').format(self.get_orientation(),ui.get_keyboard_frame(),kb,kb_self)
        def draw(self):
            '''draw a green box around kb frame, padded by 10 pixels'''
            kb=self.get_keyboard_frame()
           # print kb
            kb_self=self.convert_rect(kb,None,self)
           # print kb_self
            ui.set_color((0,1,0,0.5))
            ui.fill_rect(kb_self[0]-10,kb_self[1]-10, kb_self[2]+20,kb_self[3]+20)

            self.t3.text=('orientation {}\n'
                          'kbframe       {}\n'
                          'kbframe fixed {}\n '
                          'kbframe in V  {}\n').format(self.get_orientation(),ui.get_keyboard_frame(),kb,kb_self)