예제 #1
0
def setDragStartPosition(event):  #, undo):
    dt = event.dataTransfer
    target = DOM.eventGetTarget(event)
    clientX, clientY = event.clientX, event.clientY
    absx, absy = clientX + Window.getScrollLeft(
    ), clientY + Window.getScrollTop()

    # para arrastar um component ou bloco entre abas
    from edu.uca.renderable.block.Block import Block
    from edu.uca.util.Serializable import saveStackBlock
    from edu.uca.Workspace import getWorkspace
    from edu.uca.renderable.hardware.ComponentBlock import ComponentBlock
    from edu.uca.util.Serializable import saveComponent
    if (isinstance(getWorkspace().getMovingBlock(), ComponentBlock)):
        package = json.dumps({
            "offsetX":
            absx - DOM.getAbsoluteLeft(target),  # armagenar a origem para undo
            "offsetY":
            absy - DOM.getAbsoluteTop(target),
            "componetHardware":
            saveComponent(getWorkspace().getMovingBlock())
        })
    elif (isinstance(getWorkspace().getMovingBlock(), Block)):
        package = json.dumps({
            "offsetX":
            absx - DOM.getAbsoluteLeft(target),  # armagenar a origem para undo
            "offsetY":
            absy - DOM.getAbsoluteTop(target),
            "stackBlock":
            saveStackBlock(getWorkspace().getMovingBlock())
        })

    dt.setData('text', package)
    dt.allowedEffects = 'copy'  # using "copy" here because Windows Chrome does not like "move"
예제 #2
0
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
예제 #3
0
파일: events.py 프로젝트: brodybits/pyjs
 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)
예제 #4
0
def getCurrentOffsetPosition(event):
    target = DOM.eventGetTarget(event)
    clientX, clientY = event.clientX, event.clientY  # pega pos absoluta do ponteiro do mouse
    absx, absy = clientX + Window.getScrollLeft(
    ), clientY + Window.getScrollTop()  # ? - sempre 0,0
    return absx - DOM.getAbsoluteLeft(target), absy - DOM.getAbsoluteTop(
        target)  # subtrai pos xy do blockspad
예제 #5
0
 def onCanvasContextmenu(self, sender, event):
     x = DOM.eventGetClientX(event) - DOM.getAbsoluteLeft(
         self.canvas.getElement())
     y = DOM.eventGetClientY(event) - DOM.getAbsoluteTop(
         self.canvas.getElement())
     self.set_status('Contextmenue on Canvas at ' + str(x) + ', ' + str(y))
     DOM.eventPreventDefault(event)
예제 #6
0
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
예제 #7
0
 def __init__(self):
     """ Standard initialiser.
     """
     VerticalPanel.__init__(self)
     self.canvas = Raphael(900,700)
     self.add(self.canvas)
     x = DOM.getAbsoluteLeft(self.canvas.getElement())
     y = DOM.getAbsoluteTop(self.canvas.getElement())
     self.offset = (x,y)
예제 #8
0
 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)
예제 #9
0
 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)
예제 #10
0
def isIn(element, x, y):
    """
    Given an element and an absolute x and y, return True if the
    (x,y) coordinate is within the element. Otherwise, return False.
    """
    top = DOM.getAbsoluteTop(element)
    height = DOM.getIntAttribute(element, 'offsetHeight')
    if y >= top and y <= top + height:
        left = DOM.getAbsoluteLeft(element)
        width = DOM.getIntAttribute(element, 'offsetWidth')
        if x >= left and x <= left + width:
            return True
    return False
예제 #11
0
 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)
예제 #12
0
파일: utils.py 프로젝트: anandology/pyjamas
def isIn(element, x, y):
    """
    Given an element and an absolute x and y, return True if the
    (x,y) coordinate is within the element. Otherwise, return False.
    """
    top = DOM.getAbsoluteTop(element)
    height = DOM.getIntAttribute(element, 'offsetHeight')
    if y >= top and y <= top + height:
        left = DOM.getAbsoluteLeft(element)
        width = DOM.getIntAttribute(element, 'offsetWidth')
        if x >= left and x <= left + width:
            return True
    return False
예제 #13
0
    def _move_cursor(self, col):
        """ moves the css-styled cursor
        """
        #old style (useful for insert mode - don't delete this line for now!)
        #self.cf.setStyleName(0, col, "inputbox-square-word-cursor", highlight)

        el = self.cf.getRawElement(0, col+1)
        w = self.getWidget()
        px = self.tp.getAbsoluteLeft()
        py = self.tp.getAbsoluteTop()
        width = DOM.getOffsetWidth(el)
        px = DOM.getAbsoluteLeft(el) -  px
        py = DOM.getAbsoluteTop(el) - py 
        w.setWidgetPosition(self.cursor, px, py)
예제 #14
0
파일: tester.py 프로젝트: ASayre/UCSBsketch
 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)
예제 #15
0
 def setDragImage(self, element, x, y):
     position_absolute = DOM.getStyleAttribute(element,
                                               'position') == 'absolute'
     if position_absolute:
         self.dragLeftOffset = x + DOM.getAbsoluteLeft(element.offsetParent)
         self.dragTopOffset = y + DOM.getAbsoluteTop(element.offsetParent)
     else:
         self.dragLeftOffset = x
         self.dragTopOffset = y
     if element.tagName.lower().endswith('img'):
         src = DOM.getAttribute(element, 'src')
         element = DOM.createElement('img')
         DOM.setAttribute(element, 'src', src)
     if not self.draggingImage:
         self.createDraggingImage(element)
     else:
         self.draggingImage.setImage(element)
예제 #16
0
 def onDragStart(self, event):
     dt = event.dataTransfer
     target = DOM.eventGetTarget(event)
     clientX = event.clientX
     clientY = event.clientY
     absx = clientX + Window.getScrollLeft()
     absy = clientY + Window.getScrollTop()
     package = json.encode({"text": DOM.getInnerText(target),
                            "offsetX": absx - DOM.getAbsoluteLeft(target),
                            "offsetY": absy - DOM.getAbsoluteTop(target)})
     dt.setData('text', package)
     # using "copy" here because Windows Chrome does not like "move"
     dt.allowedEffects = 'copy'
     self.movingWidget = None
     for widget in self.children:
         if target == widget.getElement():
             self.movingWidget = widget
예제 #17
0
    def moveSlider(self, mouse_y):

        relative_y = mouse_y - DOM.getAbsoluteTop(self.getElement())
        widget_height = self.getOffsetHeight()

        # limit the position to be in the widget!
        if relative_y < 0:
            relative_y = 0
        height_range = widget_height - 10 # handle height is hard-coded
        if relative_y >= height_range:
            relative_y = height_range

        # move the handle
        DOM.setStyleAttribute(self.handle, "top", "%dpx" % relative_y)
        DOM.setStyleAttribute(self.handle, "position", "absolute")

        val_diff = self.max_value - self.min_value
        new_value = ((val_diff * relative_y) / height_range) + self.min_value
        self.setValue(new_value)
예제 #18
0
파일: DNDHelper.py 프로젝트: Afey/pyjs
 def setDragImage(self, element, x, y):
     position_absolute = DOM.getStyleAttribute(element,
                                 'position') == 'absolute'
     if position_absolute:
         self.dragLeftOffset = x + DOM.getAbsoluteLeft(
                 element.offsetParent)
         self.dragTopOffset = y + DOM.getAbsoluteTop(
                 element.offsetParent)
     else:
         self.dragLeftOffset = x
         self.dragTopOffset = y
     if element.tagName.lower().endswith('img'):
         src = DOM.getAttribute(element,'src')
         element = DOM.createElement('img')
         DOM.setAttribute(element, 'src', src)
     if not self.draggingImage:
         self.createDraggingImage(element)
     else:
         self.draggingImage.setImage(element)
예제 #19
0
 def onDragStart(self, event):
     dt = event.dataTransfer
     target = DOM.eventGetTarget(event)
     clientX = event.clientX
     clientY = event.clientY
     absx = clientX + Window.getScrollLeft()
     absy = clientY + Window.getScrollTop()
     package = json.encode({
         "text": DOM.getInnerText(target),
         "offsetX": absx - DOM.getAbsoluteLeft(target),
         "offsetY": absy - DOM.getAbsoluteTop(target)
     })
     dt.setData('text', package)
     # using "copy" here because Windows Chrome does not like "move"
     dt.allowedEffects = 'copy'
     self.movingWidget = None
     for widget in self.children:
         if target == widget.getElement():
             self.movingWidget = widget
예제 #20
0
 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
예제 #21
0
    def moveFocus(self, selection):
        focusableWidget = selection.getFocusableWidget()
        if focusableWidget is not None:
            focusableWidget.setFocus(True)
            DOM.scrollIntoView(focusableWidget.getElement())
        else:
            selectedElem = selection.getContentElem()
            containerLeft = self.getAbsoluteLeft()
            containerTop = self.getAbsoluteTop()

            left = DOM.getAbsoluteLeft(selectedElem) - containerLeft
            top = DOM.getAbsoluteTop(selectedElem) - containerTop
            width = DOM.getIntAttribute(selectedElem, "offsetWidth")
            height = DOM.getIntAttribute(selectedElem, "offsetHeight")

            DOM.setIntStyleAttribute(self.focusable, "left", "%spx" % left)
            DOM.setIntStyleAttribute(self.focusable, "top", "%spx" % top)
            DOM.setIntStyleAttribute(self.focusable, "width", "%spx" % width)
            DOM.setIntStyleAttribute(self.focusable, "height", "%spx" % height)

            DOM.scrollIntoView(self.focusable)
            Focus.focus(self.focusable)
예제 #22
0
파일: Tree.py 프로젝트: anandology/pyjamas
    def moveFocus(self, selection):
        focusableWidget = selection.getFocusableWidget()
        if focusableWidget is not None:
            focusableWidget.setFocus(True)
            DOM.scrollIntoView(focusableWidget.getElement())
        else:
            selectedElem = selection.getContentElem()
            containerLeft = self.getAbsoluteLeft()
            containerTop = self.getAbsoluteTop()

            left = DOM.getAbsoluteLeft(selectedElem) - containerLeft
            top = DOM.getAbsoluteTop(selectedElem) - containerTop
            width = DOM.getIntAttribute(selectedElem, "offsetWidth")
            height = DOM.getIntAttribute(selectedElem, "offsetHeight")

            DOM.setIntStyleAttribute(self.focusable, "left", left)
            DOM.setIntStyleAttribute(self.focusable, "top", top)
            DOM.setIntStyleAttribute(self.focusable, "width", width)
            DOM.setIntStyleAttribute(self.focusable, "height", height)

            DOM.scrollIntoView(self.focusable)
            Focus.focus(self.focusable)
예제 #23
0
 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
예제 #24
0
 def __init__(self):
     """ Standard initialiser.
     """
     VerticalPanel.__init__(self)
     GUI_Event.__init__(self)
     self.canvas = Raphael(900,700)
     #self.canvas.addListener('mousedown',self.test)
     #self.canvas.addListener('contextmenu',self.test)
     #self.tb = TextArea()
     #self.tb.setName("textBoxFormElement")
     #self.tb.setStyleAttribute({'position':'absolute',
     #    'top':'175px','left':'158px'
     #    ,'color':COLOR['maroon']
     #    ,'background':COLOR['peachpuff']
     #    ,'background-color':COLOR['peachpuff']})
     #self.tb.setSize(450,100)
     #self.tb.setReadonly('readonly')
     self.add(self.canvas)
     #self.add(self.tb)
     x = DOM.getAbsoluteLeft(self.canvas.getElement())
     y = DOM.getAbsoluteTop(self.canvas.getElement())
     self.offset = (x,y)
     '''
예제 #25
0
파일: UIObject.py 프로젝트: sofianhw/pyjs
 def getAbsoluteTop(self):
     return DOM.getAbsoluteTop(self.getElement())
예제 #26
0
 def getAbsoluteTop(self):
     return DOM.getAbsoluteTop(self.getElement())
예제 #27
0
 def onCanvasMousedown(self, sender, event):
     x = DOM.eventGetClientX(event) - DOM.getAbsoluteLeft(self.canvas.getElement())
     y = DOM.eventGetClientY(event) - DOM.getAbsoluteTop(self.canvas.getElement())
     self.set_status("Mousedown on Canvas at " + str(x) + ", " + str(y))
예제 #28
0
파일: events.py 프로젝트: brodybits/pyjs
 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))
예제 #29
0
파일: Space.py 프로젝트: minghuascode/pyj
 def addTo(self, panel):
     panel.add(self)
     self.top = DOM.getAbsoluteTop(self.getElement())
     self.left = DOM.getAbsoluteLeft(self.getElement())
예제 #30
0
파일: events.py 프로젝트: brodybits/pyjs
 def onCanvasDblClick(self,sender,event):
     x = DOM.eventGetClientX(event) - DOM.getAbsoluteLeft(self.canvas.getElement())
     y = DOM.eventGetClientY(event) - DOM.getAbsoluteTop(self.canvas.getElement())
     self.set_status('Doubleclick on Canvas at '+str(x)+', '+str(y))
예제 #31
0
파일: dash2.py 프로젝트: davelab6/telaro
 def new_mouse_pos(self, x, y):
     el = self.canvas.getElement()
     self.mouse_pos_x = x - DOM.getAbsoluteLeft(el)
     self.mouse_pos_y = y - DOM.getAbsoluteTop(el)
예제 #32
0
파일: DNDHelper.py 프로젝트: Afey/pyjs
    def onMouseMove(self, sender, x, y):
        event = DOM.eventGetCurrentEvent()
        self.mouseEvent = event
        button = DOM.eventGetButton(event)
        if not button == Event.BUTTON_LEFT:
            return
## The following commented code lets the native dnd happen in IE. sucks.
## But it may enable dragging our widgets out of IE into other apps.
#        else:
#            try:
#                self.dragWidget.getElement().dragDrop()
#                return
#            except:
#                pass

        # Adjust x and y to absolute coordinates.
        x, y = eventCoordinates(event)

        if self.dragging == DRAGGING_NO_MOVEMENT_YET:
            self.origMouseX = x
            self.origMouseY = y
            self.currentDragOperation = 'none'
            fromElement = self.dragWidget.getElement()
            # Is the widget itself draggable?
            try:
                draggable = fromElement.draggable
            except:
                draggable = False
            # if not, find the draggable element at (x, y) in the widget
            if not draggable:
                fromElement = findDraggable(sender.getElement(),
                    self.origMouseX, self.origMouseY)
            # Nothing draggable found. return.
            if fromElement is None:
                self.dragging = NOT_DRAGGING
                return
            # Get the location for the dragging widget

            #self.absParent = None

                #self.absParent = self.dragWidget.getParent()
                #self.absLeft = DOM.getStyleAttribute(fromElement, 'left')

                #print self.absLeft
                #self.absTop = DOM.getStyleAttribute(fromElement, 'top')
                #print self.absTop
                #self.origTop = DOM.getAbsoluteTop(fromElement) + parent.getAbsoluteTop()
                #self.origLeft = DOM.getAbsoluteLeft(fromElement) + parent.getAbsoluteLeft()
            self.origTop = DOM.getAbsoluteTop(fromElement)
            self.origLeft = DOM.getAbsoluteLeft(fromElement)
            #self.glassTop = DOM.getAbsoluteTop(fromElement.offsetParent)
            #self.glassLeft = DOM.getAbsoluteTop(fromElement.offsetParent)
            position_absolute = DOM.getStyleAttribute(fromElement,
                                'position') == 'absolute'
            if position_absolute:
                self.dragLeftOffset = (self.origMouseX -
                                DOM.getAbsoluteLeft(fromElement.offsetParent))
                self.dragTopOffset = (self.origMouseY -
                                DOM.getAbsoluteTop(fromElement.offsetParent))
            else:
                self.dragLeftOffset = self.origMouseX - self.origLeft
                self.dragTopOffset = self.origMouseY - self.origTop

# self.setDragImage(fromElement,
#                             self.origMouseX - self.origLeft,
#                             self.origMouseY - self.origTop)
            self.dragDataStore.elements = [fromElement]
            dragStartEvent = self.fireDNDEvent('dragstart', None,
                                               self.dragWidget)
            if not isCanceled(dragStartEvent):
                self.initFeedbackImage()
                RootPanel().add(self.draggingImage)
                self.setDragImageLocation(x, y)
                self.dragging = ACTIVELY_DRAGGING
                GlassWidget.show(self)
        elif self.dragging == ACTIVELY_DRAGGING:
            try:
                doc().selection.empty()
            except:
                wnd().getSelection().removeAllRanges()

            self.setDragImageLocation(x, y)

            # If we are still working on the previous iteration, or if we have
            # done this recently, we'll wait for the next event.
            if self.dragBusy or time.time() - self.drag_time < 0.25:
                return

            self.doDrag(event, x, y)
            self.drag_time = time.time()
예제 #33
0
파일: events.py 프로젝트: brodybits/pyjs
 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)
예제 #34
0
 def onCanvasDblClick(self, sender, event):
     x = DOM.eventGetClientX(event) - DOM.getAbsoluteLeft(
         self.canvas.getElement())
     y = DOM.eventGetClientY(event) - DOM.getAbsoluteTop(
         self.canvas.getElement())
     self.set_status('Doubleclick on Canvas at ' + str(x) + ', ' + str(y))
예제 #35
0
파일: events.py 프로젝트: brodybits/pyjs
 def onCanvasContextmenu(self, sender,event):
     x = DOM.eventGetClientX(event) - DOM.getAbsoluteLeft(self.canvas.getElement())
     y = DOM.eventGetClientY(event) - DOM.getAbsoluteTop(self.canvas.getElement())
     self.set_status('Contextmenue on Canvas at '+str(x)+', '+str(y))
     DOM.eventPreventDefault(event)
예제 #36
0
    def onMouseMove(self, sender, x, y):
        event = DOM.eventGetCurrentEvent()
        self.mouseEvent = event
        button = DOM.eventGetButton(event)
        if not button == Event.BUTTON_LEFT:
            return
## The following commented code lets the native dnd happen in IE. sucks.
## But it may enable dragging our widgets out of IE into other apps.
#        else:
#            try:
#                self.dragWidget.getElement().dragDrop()
#                return
#            except:
#                pass

# Adjust x and y to absolute coordinates.
        x, y = eventCoordinates(event)

        if self.dragging == DRAGGING_NO_MOVEMENT_YET:
            self.origMouseX = x
            self.origMouseY = y
            self.currentDragOperation = 'none'
            fromElement = self.dragWidget.getElement()
            # Is the widget itself draggable?
            try:
                draggable = fromElement.draggable
            except:
                draggable = False
            # if not, find the draggable element at (x, y) in the widget
            if not draggable:
                fromElement = findDraggable(sender.getElement(),
                                            self.origMouseX, self.origMouseY)
            # Nothing draggable found. return.
            if fromElement is None:
                self.dragging = NOT_DRAGGING
                return
            # Get the location for the dragging widget

            #self.absParent = None

            #self.absParent = self.dragWidget.getParent()
            #self.absLeft = DOM.getStyleAttribute(fromElement, 'left')

            #print self.absLeft
            #self.absTop = DOM.getStyleAttribute(fromElement, 'top')
            #print self.absTop
            #self.origTop = DOM.getAbsoluteTop(fromElement) + parent.getAbsoluteTop()
            #self.origLeft = DOM.getAbsoluteLeft(fromElement) + parent.getAbsoluteLeft()
            self.origTop = DOM.getAbsoluteTop(fromElement)
            self.origLeft = DOM.getAbsoluteLeft(fromElement)
            #self.glassTop = DOM.getAbsoluteTop(fromElement.offsetParent)
            #self.glassLeft = DOM.getAbsoluteTop(fromElement.offsetParent)
            position_absolute = DOM.getStyleAttribute(fromElement,
                                                      'position') == 'absolute'
            if position_absolute:
                self.dragLeftOffset = (
                    self.origMouseX -
                    DOM.getAbsoluteLeft(fromElement.offsetParent))
                self.dragTopOffset = (
                    self.origMouseY -
                    DOM.getAbsoluteTop(fromElement.offsetParent))
            else:
                self.dragLeftOffset = self.origMouseX - self.origLeft
                self.dragTopOffset = self.origMouseY - self.origTop

# self.setDragImage(fromElement,
#                             self.origMouseX - self.origLeft,
#                             self.origMouseY - self.origTop)
            self.dragDataStore.elements = [fromElement]
            dragStartEvent = self.fireDNDEvent('dragstart', None,
                                               self.dragWidget)
            if not isCanceled(dragStartEvent):
                self.initFeedbackImage()
                RootPanel().add(self.draggingImage)
                self.setDragImageLocation(x, y)
                self.dragging = ACTIVELY_DRAGGING
                GlassWidget.show(self)
        elif self.dragging == ACTIVELY_DRAGGING:
            try:
                doc().selection.empty()
            except:
                wnd().getSelection().removeAllRanges()

            self.setDragImageLocation(x, y)

            # If we are still working on the previous iteration, or if we have
            # done this recently, we'll wait for the next event.
            if self.dragBusy or time.time() - self.drag_time < 0.25:
                return

            self.doDrag(event, x, y)
            self.drag_time = time.time()
예제 #37
0
    def onClick(self, sender, event):

        # work out the relative position of cursor
        mouse_y = DOM.eventGetClientY(event) - \
                   DOM.getAbsoluteTop(sender.getElement())
        self.moveSlider(mouse_y)
예제 #38
0
파일: Space.py 프로젝트: minghuascode/pyj
 def addTo(self, panel):
     panel.add(self)
     self.top = DOM.getAbsoluteTop(self.getElement())
     self.left = DOM.getAbsoluteLeft(self.getElement())
예제 #39
0
 def onCanvasMousedown(self, sender, event):
     x = DOM.eventGetClientX(event) - DOM.getAbsoluteLeft(
         self.canvas.getElement())
     y = DOM.eventGetClientY(event) - DOM.getAbsoluteTop(
         self.canvas.getElement())
     self.set_status('Mousedown on Canvas at ' + str(x) + ', ' + str(y))
예제 #40
0
 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)