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


Python DOM.eventGetClientX方法代码示例

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


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

示例1: onDrop

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import eventGetClientX [as 别名]
    def onDrop(self, event):
        dt = event.dataTransfer
        text = dt.getData('text')
        package = json.decode(text)
        x = DOM.eventGetClientX(event)
        y = DOM.eventGetClientY(event)
        scrollY = Window.getScrollTop()
        scrollX = Window.getScrollLeft()
        offsetX = int(package['offsetX'])
        offsetY = int(package['offsetY'])
        at = self.getAbsoluteTop()
        al = self.getAbsoluteLeft()
        posX, posY = x - (al - scrollX), y - (at - scrollY)
        w = DragWidget6(package['text'])
        self.add(w)
        makeDraggable(w)
        # firefox seems to be off-by-one in x.
        # firefox-specific code?
        #w.setStyleAttribute('left', posX - offsetX -1)
        w.setStyleAttribute('left', posX - offsetX)
        w.setStyleAttribute('top', posY - offsetY)
        w.removeStyleName('invisible')
        self.addMessage(
            "top:%s, left:%s, cy:%s cx:%s, sy:%s sx:%s dropy:%s dropx:%s" % (
            at, al, y, x, scrollY, scrollX, posY, posX))

        DOM.eventPreventDefault(event)
开发者ID:anandology,项目名称:pyjamas,代码行数:29,代码来源:DNDTest.py

示例2: action

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import eventGetClientX [as 别名]
 def action(self,element,event):
     x = DOM.eventGetClientX(event) - self.ox
     y = DOM.eventGetClientY(event) - self.oy
     DOM.eventCancelBubble(event,True)
     DOM.eventPreventDefault(event)
     #alert('clic %s %s'%(x,y))
     self._action(x,y)
开发者ID:labase,项目名称:jeppeto,代码行数:9,代码来源:pyjamas_factory.py

示例3: onElementContextmenu

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import eventGetClientX [as 别名]
 def onElementContextmenu(self, sender,event):
     x = DOM.eventGetClientX(event) - DOM.getAbsoluteLeft(self.canvas.getElement())
     y = DOM.eventGetClientY(event) - DOM.getAbsoluteTop(self.canvas.getElement())
     s = self.desc[self.elements.index(sender)]
     self.set_status('Contextmenue on Element '+s+' at '+str(x)+', '+str(y))
     DOM.eventCancelBubble(event,True)
     DOM.eventPreventDefault(event)
开发者ID:brodybits,项目名称:pyjs,代码行数:9,代码来源:events.py

示例4: fireMouseEvent

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import eventGetClientX [as 别名]
def fireMouseEvent(listeners, sender, event):
    x = DOM.eventGetClientX(event) - DOM.getAbsoluteLeft(sender.getElement())
    y = DOM.eventGetClientY(event) - DOM.getAbsoluteTop(sender.getElement())

    etype = DOM.eventGetType(event)
    if etype == "mousedown":
        for listener in listeners:
            listener.onMouseDown(sender, x, y)
        return True
    elif etype == "mouseup":
        for listener in listeners:
            listener.onMouseUp(sender, x, y)
        return True
    elif etype == "mousemove":
        for listener in listeners:
            listener.onMouseMove(sender, x, y)
        return True
    elif etype == "mouseover":
        from_element = DOM.eventGetFromElement(event)
        if not DOM.isOrHasChild(sender.getElement(), from_element):
            for listener in listeners:
                listener.onMouseEnter(sender)
        return True
    elif etype == "mouseout":
        to_element = DOM.eventGetToElement(event)
        if not DOM.isOrHasChild(sender.getElement(), to_element):
            for listener in listeners:
                listener.onMouseLeave(sender)
        return True
    return False
开发者ID:anandology,项目名称:pyjamas,代码行数:32,代码来源:MouseListener.py

示例5: onClick

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import eventGetClientX [as 别名]
 def onClick(self, sender=None):
     self.setFocus(True);
     # work out the relative position of cursor
     event = DOM.eventGetCurrentEvent()
     mouse_x = DOM.eventGetClientX(event) + Window.getScrollLeft()
     mouse_y = DOM.eventGetClientY(event) + Window.getScrollTop()
     self.moveControl(mouse_x - self.getAbsoluteLeft(),
                      mouse_y - self.getAbsoluteTop())
开发者ID:emk,项目名称:pyjamas,代码行数:10,代码来源:Controls.py

示例6: test

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import eventGetClientX [as 别名]
    def test(self,elm,event,msg='foi'):
        location = None
        JS('''
           location = window.location.hostname;

           ''')
        if 'localhost' == location: location +=':8004'
        return location
        x = DOM.eventGetClientX(event)
        y = DOM.eventGetClientY(event)
        alert ('%s %s %s'%(msg,x,y))
开发者ID:labase,项目名称:jeppeto,代码行数:13,代码来源:pyjamas_factory.py

示例7: onClickDefault

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import eventGetClientX [as 别名]
    def onClickDefault(self, sender):
        # don't shown property editor if they clicked on nothing
        if None == self.chart.getTouchedPoint():
            return

        event = DOM.eventGetCurrentEvent()

        # load properties of clicked-on slice into form
        self.copyChartPropertiesIntoForm(self.chart.getTouchedPoint())
        if self.isFirstTime:
            # initially put upper left corner wherever they clicked...
            self.setPopupPosition(
                        Window.getScrollLeft()+ DOM.eventGetClientX(event),
                        Window.getScrollTop() + DOM.eventGetClientX(event))
            self.show()
            self.isFirstTime = False

        else:
            # ...thereafter, just stay whereever they dragged it to
            self.show()
开发者ID:FreakTheMighty,项目名称:pyjamas,代码行数:22,代码来源:GChartExample20.py

示例8: onContextMenu

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import eventGetClientX [as 别名]
  def onContextMenu(self, sender):
    event = DOM.eventGetCurrentEvent()
    subMenu = MenuBar(True)
    subMenu.addItem("<code>Code</code>", True, self)
    subMenu.addItem("<strike>Strikethrough</strike>", True, self)
    subMenu.addItem("<u>Underlined</u>", True, self)

    x = DOM.eventGetClientX(event) + 2
    y = DOM.eventGetClientY(event) + 2

    popup = ContextMenuPopupPanel(subMenu)
    popup.showAt(x, y)
开发者ID:davidmi,项目名称:cryptogram,代码行数:14,代码来源:Menus.py

示例9: onBrowserEvent

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import eventGetClientX [as 别名]
 def onBrowserEvent(self, event):
    kind = DOM.eventGetType(event)
    x = DOM.eventGetClientX(event) - DOM.getAbsoluteLeft(self.getElement())
    y = DOM.eventGetClientY(event) - DOM.getAbsoluteTop(self.getElement())
    y = HEIGHT - y
    if kind == "mousedown":
       self.onMouseDown(x,y)
       self._dragging = True
    elif kind == "mousemove" and self._dragging:
       self.onMouseDrag(x,y)
    elif (kind == "mouseup" or kind == "mouseout") and self._dragging:
       self._dragging = False
       self.onMouseUp(x,y)
开发者ID:ASayre,项目名称:UCSBsketch,代码行数:15,代码来源:PyjSketchGUI.py

示例10: onBrowserEvent

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import eventGetClientX [as 别名]
 def onBrowserEvent(self, event):
    print "Event happened"
    kind = DOM.eventGetType(event)
    x = DOM.eventGetClientX(event) - DOM.getAbsoluteLeft(self.canvas.getElement())
    y = DOM.eventGetClientY(event) - DOM.getAbsoluteTop(self.canvas.getElement())
    print "Type of event: %s" % (kind)
    if kind == "mousedown":
       self._dragging = True
       self.onMouseDown(x,y)
    elif kind == "mousemove" and self._dragging:
       self.onMouseDrag(x,y)
    elif (kind == "mouseup" or kind == "mouseout") and self._dragging:
       self._dragging = False
       self.onMouseUp(x,y)
开发者ID:ASayre,项目名称:UCSBsketch,代码行数:16,代码来源:tester.py

示例11: onBrowserEvent

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import eventGetClientX [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

示例12: onClick

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import eventGetClientX [as 别名]
 def onClick(self, sender, evt):
     x = DOM.eventGetClientX(evt)-DOM.getAbsoluteLeft(self.getElement())
     y = DOM.eventGetClientY(evt)-DOM.getAbsoluteTop(self.getElement())
     xth = int(x/uwidth)
     yth = int(y/uheight)
     box = self.map[yth][xth]
     if not box:
         return
     box.toggleSelect()
     if not box.selected:
         self.selected_box = None
     elif self.selected_box==None:
         self.selected_box = box
     elif box.img != self.selected_box.img:
         # change selection
         self.selected_box.unSelect()
         self.selected_box = box
     else:
         sbox = self.selected_box
         print 'check'
         result = False
         if box.xth<sbox.xth:
             print (box.yth,box.xth), (sbox.yth,sbox.xth)
             result = checkllk(self.map, (box.yth,box.xth), (sbox.yth,sbox.xth))
         else:
             print (sbox.yth,sbox.xth), (box.yth,box.xth)
             result = checkllk(self.map, (sbox.yth,sbox.xth), (box.yth,box.xth))
         if result:
             print 'path:', result
             sbox.dead()
             self.map[sbox.yth][sbox.xth] = 0
             box.dead()
             self.map[box.yth][box.xth] = 0
             self.selected_box = None
         else:
             print 'fail'
             self.selected_box.unSelect()
             self.selected_box = box
开发者ID:yihuang,项目名称:huangyilib,代码行数:40,代码来源:LlkApp.py

示例13: onCanvasMouseup

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import eventGetClientX [as 别名]
 def onCanvasMouseup(self,obj,event):
     x = DOM.eventGetClientX(event) - DOM.getAbsoluteLeft(self.canvas.getElement())
     y = DOM.eventGetClientY(event) - DOM.getAbsoluteTop(self.canvas.getElement())
     self.set_status('Mousemove on Canvas at '+str(x)+', '+str(y))
开发者ID:brodybits,项目名称:pyjs,代码行数:6,代码来源:events.py

示例14: onElementMousemove

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import eventGetClientX [as 别名]
 def onElementMousemove(self, sender, event):
     x = DOM.eventGetClientX(event) - DOM.getAbsoluteLeft(self.canvas.getElement())
     y = DOM.eventGetClientY(event) - DOM.getAbsoluteTop(self.canvas.getElement())
     s = self.desc[self.elements.index(sender)]
     self.set_status("Mousemove on Element " + s + " at " + str(x) + ", " + str(y))
     DOM.eventCancelBubble(event, True)
开发者ID:jakebarnwell,项目名称:PythonGenerator,代码行数:8,代码来源:events.py

示例15: onElementDblClick

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import eventGetClientX [as 别名]
 def onElementDblClick(self,sender,event):
     x = DOM.eventGetClientX(event) - DOM.getAbsoluteLeft(self.canvas.getElement())
     y = DOM.eventGetClientY(event) - DOM.getAbsoluteTop(self.canvas.getElement())
     s = self.desc[self.elements.index(sender)]
     self.set_status('Doubleclick on Element '+s+' at '+str(x)+', '+str(y))
     DOM.eventCancelBubble(event,True)
开发者ID:brodybits,项目名称:pyjs,代码行数:8,代码来源:events.py


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