当前位置: 首页>>代码示例>>Python>>正文


Python DOM.eventGetTarget方法代码示例

本文整理汇总了Python中pyjamas.DOM.eventGetTarget方法的典型用法代码示例。如果您正苦于以下问题:Python DOM.eventGetTarget方法的具体用法?Python DOM.eventGetTarget怎么用?Python DOM.eventGetTarget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyjamas.DOM的用法示例。


在下文中一共展示了DOM.eventGetTarget方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: onBrowserEvent

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import eventGetTarget [as 别名]
    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
开发者ID:anandology,项目名称:pyjamas,代码行数:55,代码来源:Tree.py

示例2: onDragStart

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import eventGetTarget [as 别名]
 def onDragStart(self, event):
     dt = event.dataTransfer
     target = DOM.eventGetTarget(event)
     target = Widget(Element=target)
     id = target.getID()
     dt.setData("Text", "Dropped %s" % target.getID())
     dt.effectAllowed = 'copy'
     if id == 'imgdrag1':
         parent = self.getParent()
         while not hasattr(parent, 'h2'):
             parent = parent.getParent()
         dt.setDragImage(parent.h2.getElement(), 10, 10)
     elif id == 'imgdrag2':
         dt.setDragImage(doc().getElementById('logo'), 10, 10)
     elif id == 'imgdrag3':
         # OK, it's a bit of a cheat, but the following works on current
         # Opera, IE, Firefox, Safari, Chrome.
         ctx = GWTCanvas(50, 50)
         self.makeCanvasImg(ctx)
         try:
             img = DOM.createImg()
             DOM.setAttribute(img, 'src', ctx.canvas.toDataURL())
             dt.setDragImage(img, 25, 25)
         except:
             dt.setDragImage(ctx.canvas, 25, 25)
开发者ID:anandology,项目名称:pyjamas,代码行数:27,代码来源:DNDTest.py

示例3: onEventPreview

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import eventGetTarget [as 别名]
 def onEventPreview(self, event):
     type = DOM.eventGetType(event)
     if type == "click":
         target = DOM.eventGetTarget(event)
         parentMenuElement = self.item.getParentMenu().getElement()
         if DOM.isOrHasChild(parentMenuElement, target):
             return False
     return PopupPanel.onEventPreview(self, event)
开发者ID:FreakTheMighty,项目名称:pyjamas,代码行数:10,代码来源:MenuBarPopupPanel.py

示例4: onDragOver

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import eventGetTarget [as 别名]
 def onDragOver(self, event):
     target = DOM.eventGetTarget(event)
     t = Widget(Element=target)
     dt = event.dataTransfer
     dt.dropEffect = 'copy'
     class_names = t.getStyleName()
     if class_names is not None:
         if 'drophere' in class_names:
             DOM.eventPreventDefault(event)
开发者ID:anandology,项目名称:pyjamas,代码行数:11,代码来源:DNDTest.py

示例5: onDragLeave

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import eventGetTarget [as 别名]
 def onDragLeave(self, event):
     target = DOM.eventGetTarget(event)
     t = Widget(Element=target)
     try:
         class_names = t.getStyleName()
     except:
         class_names = None
     if class_names is not None:
         if 'drophere' in class_names:
             t.removeStyleName('dragover')
开发者ID:anandology,项目名称:pyjamas,代码行数:12,代码来源:DNDTest.py

示例6: onDrop

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import eventGetTarget [as 别名]
 def onDrop(self, event):
     dt = event.dataTransfer
     text = dt.getData('Text')
     target = DOM.eventGetTarget(event)
     t = Widget(Element=target)
     class_names = t.getStyleName()
     if class_names is not None:
         if 'drophere' in class_names:
             self.addMessage('%s onto %s<br>effectAllowed=%s, dropEffect=%s'
             % (text, target.id, dt.effectAllowed, dt.dropEffect))
             DOM.eventPreventDefault(event)
开发者ID:anandology,项目名称:pyjamas,代码行数:13,代码来源:DNDTest.py

示例7: onEventPreview

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import eventGetTarget [as 别名]
 def onEventPreview(self, event):
     # preventDefault on mousedown events, outside of the
     # dialog, to stop text-selection on dragging
     type = DOM.eventGetType(event)
     if type == "mousedown":
         target = DOM.eventGetTarget(event)
         elem = self.caption.getElement()
         event_targets_popup = target and DOM.isOrHasChild(elem, target)
         if event_targets_popup:
             DOM.eventPreventDefault(event)
     return PopupPanel.onEventPreview(self, event)
开发者ID:nielsonsantana,项目名称:emath,代码行数:13,代码来源:PopupPagina.py

示例8: onEventPreview

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import eventGetTarget [as 别名]
    def onEventPreview(self, event):
        type = DOM.eventGetType(event)
        if type == "click":
            target = DOM.eventGetTarget(event)
            parentMenuElement = self.item.getElement()
            if DOM.isOrHasChild(parentMenuElement, target):
                if self.item.onBrowserEvent(event):
                    self.hide()
                return True

        return PopupPanel.onEventPreview(self, event)
开发者ID:FreakTheMighty,项目名称:pyjamas,代码行数:13,代码来源:ContextMenuPopupPanel.py

示例9: onDragEnter

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import eventGetTarget [as 别名]
 def onDragEnter(self, event):
     target = DOM.eventGetTarget(event)
     t = Widget(Element=target)
     try:
         class_names = t.getStyleName()
     except:
         class_names = None
     if class_names is not None:
         if 'drophere' in class_names:
             t.addStyleName('dragover')
             DOM.eventPreventDefault(event)
开发者ID:anandology,项目名称:pyjamas,代码行数:13,代码来源:DNDTest.py

示例10: onEventPreview

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import eventGetTarget [as 别名]
 def onEventPreview(self, event):
     # preventDefault on mousedown events, outside of the
     # dialog, to stop text-selection on dragging
     type = DOM.eventGetType(event)
     print "onEventPreview", event, type
     if type == 'mousedown':
         target = DOM.eventGetTarget(event)
         event_targets_control = target and DOM.isOrHasChild(self.getElement(), target)
         print "onEventPreview", target, event_targets_control
         if event_targets_control:
             DOM.eventPreventDefault(event)
     return VerticalSliderDemo.onEventPreview(self, event)
开发者ID:pombredanne,项目名称:pyjamas-desktop,代码行数:14,代码来源:Controls.py

示例11: getEventTargetCell

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import eventGetTarget [as 别名]
    def getEventTargetCell(self, event):
        td = DOM.eventGetTarget(event)
        while td is not None:
            if DOM.getAttribute(td, "tagName").lower() == "td":
                tr = DOM.getParent(td)
                body = DOM.getParent(tr)
                if DOM.compare(body, self.bodyElem):
                    return td
            if DOM.compare(td, self.bodyElem):
                return None
            td = DOM.getParent(td)

        return None
开发者ID:andreyvit,项目名称:pyjamas,代码行数:15,代码来源:HTMLTable.py

示例12: onBrowserEvent

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import eventGetTarget [as 别名]
    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
开发者ID:FreakTheMighty,项目名称:pyjamas,代码行数:19,代码来源:MenuBar.py

示例13: onBrowserEvent

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import eventGetTarget [as 别名]
    def onBrowserEvent(self, event):
        typ = DOM.eventGetType(event)

        if typ == "mousedown":
            target = DOM.eventGetTarget(event)
            if DOM.isOrHasChild(self.splitElem, target):
                self.startResizingFrom(DOM.eventGetClientX(event) -
                                       self.getAbsoluteLeft(),
                          DOM.eventGetClientY(event) - self.getAbsoluteTop())
                DOM.setCapture(self.getElement())
                DOM.eventPreventDefault(event)

        elif typ == "mouseup":
            DOM.releaseCapture(self.getElement())
            self.stopResizing()

        elif typ == 'mousemove':
            if self.isResizing:
                #assert DOM.getCaptureElement() is not None
                self.onSplitterResize(DOM.eventGetClientX(event) -
                                      self.getAbsoluteLeft(),
                          DOM.eventGetClientY(event) - self.getAbsoluteTop())
                DOM.eventPreventDefault(event)
开发者ID:certik,项目名称:pyjamas,代码行数:25,代码来源:splitpanel.py

示例14: setTarget

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import eventGetTarget [as 别名]
 def setTarget(self, target=None):
     if target is not None:
         self.target = target
     else:
         self.target = DOM.eventGetTarget(self.evt)
开发者ID:Afey,项目名称:pyjs,代码行数:7,代码来源:DragEvent.py

示例15: onBrowserEvent

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import eventGetTarget [as 别名]
 def onBrowserEvent(self, event):
     if DOM.eventGetType(event) == "click":
         index = self.getDividerIndex(DOM.eventGetTarget(event))
         if index != -1:
             self.showStack(index)
开发者ID:Afey,项目名称:pyjs,代码行数:7,代码来源:StackPanel.py


注:本文中的pyjamas.DOM.eventGetTarget方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。