예제 #1
0
 def onEventPreview(self, event):
     type = DOM.eventGetType(event)
     if type == "keydown":
         return (self.onKeyDownPreview(
             DOM.eventGetKeyCode(event),
             KeyboardListener.getKeyboardModifiers(event))
                 and (not self.modal or self._event_targets_popup(event)))
     elif type == "keyup":
         return (self.onKeyUpPreview(
             DOM.eventGetKeyCode(event),
             KeyboardListener.getKeyboardModifiers(event))
                 and (not self.modal or self._event_targets_popup(event)))
     elif type == "keypress":
         return (self.onKeyPressPreview(
             DOM.eventGetKeyCode(event),
             KeyboardListener.getKeyboardModifiers(event))
                 and (not self.modal or self._event_targets_popup(event)))
     elif (type == "mousedown" or type == "blur"):
         if DOM.getCaptureElement() is not None:
             return True
         if self.autoHide and not self._event_targets_popup(event):
             self.hide(True)
             return True
     elif (type == "mouseup" or type == "click" or type == "mousemove"
           or type == "dblclick"):
         if DOM.getCaptureElement() is not None:
             return True
     return not self.modal or self._event_targets_popup(event)
예제 #2
0
파일: Tree.py 프로젝트: anandology/pyjamas
    def onBrowserEvent(self, event):
        etype = DOM.eventGetType(event)

        if etype == "click":
            e = DOM.eventGetTarget(event)
            if not self.shouldTreeDelegateFocusToElement(e) and \
                            self.curSelection is not None:
                self.setFocus(True)
        elif etype in MouseListener.MOUSE_EVENTS:
            if etype == "mousedown":
                self.elementClicked(self.root, DOM.eventGetTarget(event))
            MouseListener.fireMouseEvent(self.mouseListeners, self, event)
        elif etype == "blur" or etype == "focus":
            FocusListener.fireFocusEvent(self.focusListeners, self, event)
        elif etype == "keydown":
            if self.curSelection is None:
                if self.root.getChildCount() > 0:
                    self.onSelection(self.root.getChild(0), True)
                Widget.onBrowserEvent(self, event)
                return

            if self.lastEventType == "keydown":
                return

            keycode = DOM.eventGetKeyCode(event)
            if keycode == KeyboardListener.KEY_UP:
                self.moveSelectionUp(self.curSelection, True)
                DOM.eventPreventDefault(event)
            elif keycode == KeyboardListener.KEY_DOWN:
                self.moveSelectionDown(self.curSelection, True)
                DOM.eventPreventDefault(event)
            elif keycode == KeyboardListener.KEY_LEFT:
                if self.curSelection.getState():
                    self.curSelection.setState(False)
                DOM.eventPreventDefault(event)
            elif keycode == KeyboardListener.KEY_RIGHT:
                if not self.curSelection.getState():
                    self.curSelection.setState(True)
                DOM.eventPreventDefault(event)
        elif etype == "keyup":
            if DOM.eventGetKeyCode(event) == KeyboardListener.KEY_TAB:
                chain = []
                self.collectElementChain(chain, self.getElement(),
                                         DOM.eventGetTarget(event))
                item = self.findItemByChain(chain, 0, self.root)
                if item != self.getSelectedItem():
                    self.setSelectedItem(item, True)
        elif etype == "keypress":
            KeyboardListener.fireKeyboardEvent(self.keyboardListeners,
                                               self, event)

        Widget.onBrowserEvent(self, event)
        self.lastEventType = etype
예제 #3
0
    def onBrowserEvent(self, event):
        etype = DOM.eventGetType(event)

        if etype == "click":
            e = DOM.eventGetTarget(event)
            if not self.shouldTreeDelegateFocusToElement(e) and \
                            self.curSelection is not None:
                self.setFocus(True)
        elif etype in MouseListener.MOUSE_EVENTS:
            if etype == "mousedown":
                self.elementClicked(self.root, DOM.eventGetTarget(event))
            MouseListener.fireMouseEvent(self.mouseListeners, self, event)
        elif etype == "blur" or etype == "focus":
            FocusListener.fireFocusEvent(self.focusListeners, self, event)
        elif etype == "keydown":
            if self.curSelection is None:
                if self.root.getChildCount() > 0:
                    self.onSelection(self.root.getChild(0), True)
                Widget.onBrowserEvent(self, event)
                return

            if self.lastEventType == "keydown":
                return

            keycode = DOM.eventGetKeyCode(event)
            if keycode == KeyboardListener.KEY_UP:
                self.moveSelectionUp(self.curSelection, True)
                DOM.eventPreventDefault(event)
            elif keycode == KeyboardListener.KEY_DOWN:
                self.moveSelectionDown(self.curSelection, True)
                DOM.eventPreventDefault(event)
            elif keycode == KeyboardListener.KEY_LEFT:
                if self.curSelection.getState():
                    self.curSelection.setState(False)
                DOM.eventPreventDefault(event)
            elif keycode == KeyboardListener.KEY_RIGHT:
                if not self.curSelection.getState():
                    self.curSelection.setState(True)
                DOM.eventPreventDefault(event)
        elif etype == "keyup":
            if DOM.eventGetKeyCode(event) == KeyboardListener.KEY_TAB:
                chain = []
                self.collectElementChain(chain, self.getElement(),
                                         DOM.eventGetTarget(event))
                item = self.findItemByChain(chain, 0, self.root)
                if item != self.getSelectedItem():
                    self.setSelectedItem(item, True)
        elif etype == "keypress":
            KeyboardListener.fireKeyboardEvent(self.keyboardListeners, self,
                                               event)

        Widget.onBrowserEvent(self, event)
        self.lastEventType = etype
예제 #4
0
    def onBrowserEvent(self, event) :
        type = DOM.eventGetType(event)
        if type == "click":
            self.onClick(self)

        elif type == "keydown":
            modifiers = KeyboardListener.getKeyboardModifiers(event)
            if hasattr(self.keyDelegate, "onKeyDown"):
                self.keyDelegate.onKeyDown(self, DOM.eventGetKeyCode(event),
                                       modifiers)
예제 #5
0
    def onBrowserEvent(self, event) :
        type = DOM.eventGetType(event)
        if type == "click":
            self.onClick(self)

        elif type == "keydown":
            modifiers = KeyboardListener.getKeyboardModifiers(event)
            if hasattr(self.keyDelegate, "onKeyDown"):
                self.keyDelegate.onKeyDown(self, DOM.eventGetKeyCode(event),
                                       modifiers)
예제 #6
0
 def onEventPreview(self, event):
     type = DOM.eventGetType(event)
     if type == "keydown":
         return (    self.onKeyDownPreview(
                         DOM.eventGetKeyCode(event),
                         KeyboardListener.getKeyboardModifiers(event)
                         )
                 and (not self.modal or self._event_targets_popup(event))
                )
     elif type == "keyup":
         return (    self.onKeyUpPreview(
                         DOM.eventGetKeyCode(event),
                         KeyboardListener.getKeyboardModifiers(event)
                         )
                 and (not self.modal or self._event_targets_popup(event))
                )
     elif type == "keypress":
         return (    self.onKeyPressPreview(
                         DOM.eventGetKeyCode(event),
                         KeyboardListener.getKeyboardModifiers(event)
                         )
                 and (not self.modal or self._event_targets_popup(event))
                )
     elif (   type == "mousedown"
           or type == "blur"
          ):
         if DOM.getCaptureElement() is not None:
             return True
         if self.autoHide and not self._event_targets_popup(event):
             self.hide(True)
             return True
     elif (   type == "mouseup"
           or type == "click"
           or type == "mousemove"
           or type == "dblclick"
          ):
         if DOM.getCaptureElement() is not None:
             return True
     return not self.modal or self._event_targets_popup(event)