def onBrowserEvent(self, event):
     Widget.onBrowserEvent(self, event)
     event_type = DOM.eventGetType(event)
     if event_type == "click":
         DOM.eventPreventDefault(event)
         if self.targetHistoryToken is not None:
             History.newItem(self.targetHistoryToken)
示例#2
0
 def onBrowserEvent(self, event):
     Widget.onBrowserEvent(self, event)
     type = DOM.eventGetType(event)
     if type == "load":
         for listener in self.loadListeners:
             listener.onImageLoad(self)
     elif type == "error":
         for listener in self.loadListeners:
             listener.onImageError(self)
示例#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):
        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
示例#5
0
    def onBrowserEvent(self, event):
        Widget.onBrowserEvent(self, event)

        item = self.findItem(DOM.eventGetTarget(event))
        if item is None:
            return False

        type = DOM.eventGetType(event)
        if type == "click":
            self.doItemAction(item, True)
            return True
        elif type == "mouseover":
            self.itemOver(item)
        elif type == "mouseout":
            self.itemOver(None)

        return False
示例#6
0
    def onBrowserEvent(self, event):
        Widget.onBrowserEvent(self, event)

        item = self.findItem(DOM.eventGetTarget(event))
        if item is None:
            return False

        type = DOM.eventGetType(event)
        if type == "click":
            self.doItemAction(item, True)
            return True
        elif type == "mouseover":
            self.itemOver(item)
        elif type == "mouseout":
            self.itemOver(None)

        return False
示例#7
0
文件: Composite.py 项目: Afey/pyjs
 def onBrowserEvent(self, event):
     Widget.onBrowserEvent(self, event) # takes care of auto-handlers
     self.widget.onBrowserEvent(event)
示例#8
0
 def onBrowserEvent(self, event):
     Widget.onBrowserEvent(self, event)  # takes care of auto-handlers
     self.widget.onBrowserEvent(event)