def onDrop(self, event): #print "BlockHolder: onDrop" DOM.eventStopPropagation( event) # nao deixar ir para o onDrop de BlocksPad if self.subBlock == getWorkspace().getMovingBlock(): return # retirou e colocou o mesmo bloco #--------------------------------------------------- if getWorkspace().getMovingBlock().original: getWorkspace().setMovingBlock(getWorkspace().cloneBlock( getWorkspace().getMovingBlock())) #undo = (getWorkspace().getBlockList().removeBlocks, [getWorkspace().getMovingBlock()]) #else: undo = getWorkspace().getUndo() #--------------------------------------------------- if self.up: #self.argument.statementArgumentType == UP_ARG #undo = (self.removeUpperBlock, [undo, self.block.getStyleAttribute('left'), self.block.getStyleAttribute('top'), getWorkspace().getMovingBlock().original]) #do = (self.addUpperBlock, [getWorkspace().getMovingBlock(), getWorkspace().getMovingBlock().original, event]) self.addUpperBlock(getWorkspace().getMovingBlock(), getWorkspace().getMovingBlock().original, event) # else: #do = (self.addSubBlock, [getWorkspace().getMovingBlock(), getWorkspace().getMovingBlock().original]) self.addSubBlock(getWorkspace().getMovingBlock(), getWorkspace().getMovingBlock().original) # #--------------------------------------------------- #history.add(do, undo) from edu.uca.util.Serializable import stateChange stateChange()
def onMouseDown(self, sender, x, y): event = DOM.eventGetCurrentEvent() event_button = DOM.eventGetButton(event) if event_button == Event.BUTTON_RIGHT: from edu.uca.renderable.block.MainBlock import MainBlock if not self.original and not isinstance(self, MainBlock): self.buttonRightDown = self DOM.eventStopPropagation(event)
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.findItem(target): self.hide() DOM.eventCancelBubble(event, True) DOM.eventStopPropagation(event) return True return PopupPanel.onEventPreview(self, event)
def onMouseUp(self, sender, x, y): event = DOM.eventGetCurrentEvent() event_button = DOM.eventGetButton(event) if event_button == Event.BUTTON_RIGHT: from edu.uca.renderable.block.MainBlock import MainBlock if self.buttonRightDown == self and not self.original and not isinstance( self, MainBlock): print "click Right Button " + self.name self.buttonRightDown = None from edu.uca.util.Serializable import saveStackBlock, loadStackBlock cloneStack = loadStackBlock(saveStackBlock(self)) cloneStack.changeTexts() self.blockPad.addBlock(cloneStack, self.getAbsoluteLeft() + 10, self.getAbsoluteTop() + 10, False) DOM.eventStopPropagation(event)
def onBrowserEvent(self, event): StringArgument.onBrowserEvent(self, event) if DOM.eventGetType(event) == "mousedown": if self._event_targets_btn(event): DOM.eventStopPropagation(event) MouseHandler.onBrowserEvent(self, event)
def onBrowserEvent(self, event): # Should not act on button if disabled. if not self.isEnabled(): # This can happen when events are bubbled up from # non-disabled children return event_type = DOM.eventGetType(event) if event_type == "click": # If clicks are currently disallowed, keep it from bubbling or # being passed to the superclass. if not self.allowClick: DOM.eventStopPropagation(event) return elif event_type == "mousedown": if DOM.eventGetButton(event) == Event.BUTTON_LEFT: self.setFocus(True) self.onClickStart() DOM.setCapture(self.getElement()) self.isCapturing = True # Prevent dragging (on some browsers) DOM.eventPreventDefault(event) elif event_type == "mouseup": if self.isCapturing: self.isCapturing = False DOM.releaseCapture(self.getElement()) if self.isHovering() and \ DOM.eventGetButton(event) == Event.BUTTON_LEFT: self.onClick() elif event_type == "mousemove": if self.isCapturing: # Prevent dragging (on other browsers) DOM.eventPreventDefault(event) elif event_type == "mouseout": to = DOM.eventGetToElement(event) if (DOM.isOrHasChild(self.getElement(), DOM.eventGetTarget(event)) and (to is None or not DOM.isOrHasChild(self.getElement(), to))): if self.isCapturing: self.onClickCancel() self.setHovering(False) elif event_type == "mouseover": if DOM.isOrHasChild(self.getElement(), DOM.eventGetTarget(event)): self.setHovering(True) if self.isCapturing: self.onClickStart() elif event_type == "blur": if self.isFocusing: self.isFocusing = False self.onClickCancel() elif event_type == "losecapture": if self.isCapturing: self.isCapturing = False self.onClickCancel() ButtonBase.onBrowserEvent(self, event) # Synthesize clicks based on keyboard events AFTER the normal # key handling. if (DOM.eventGetTypeInt(event) & Event.KEYEVENTS) == 0: return keyCode = DOM.eventGetKeyCode(event) if event_type == "keydown": if keyCode == ' ': self.isFocusing = True self.onClickStart() elif event_type == "keyup": if self.isFocusing and keyCode == ' ': self.isFocusing = False self.onClick() elif event_type == "keypress": if keyCode == '\n' or keyCode == '\r': self.onClickStart() self.onClick()
def onBrowserEvent(self, event): # Should not act on button if disabled. if not self.getEnabled(): # This can happen when events are bubbled up from # non-disabled children return event_type = DOM.eventGetType(event) if event_type == "click": # If clicks are currently disallowed, keep it from bubbling or # being passed to the superclass. if not self.allowClick: DOM.eventStopPropagation(event) return elif event_type == "mousedown": if DOM.eventGetButton(event) == Event.BUTTON_LEFT: self.setFocus(True) self.onClickStart() DOM.setCapture(self.getElement()) self.isCapturing = True # Prevent dragging (on some browsers) DOM.eventPreventDefault(event) elif event_type == "mouseup": if self.isCapturing: self.isCapturing = False DOM.releaseCapture(self.getElement()) if self.isHovering() and \ DOM.eventGetButton(event) == Event.BUTTON_LEFT: self.onClick() elif event_type == "mousemove": if self.isCapturing: # Prevent dragging (on other browsers) DOM.eventPreventDefault(event) elif event_type == "mouseout": to = DOM.eventGetToElement(event) if (DOM.isOrHasChild(self.getElement(), DOM.eventGetTarget(event)) and (to is None or not DOM.isOrHasChild(self.getElement(), to))): if self.isCapturing: self.onClickCancel() self.setHovering(False) elif event_type == "mouseover": if DOM.isOrHasChild(self.getElement(), DOM.eventGetTarget(event)): self.setHovering(True) if self.isCapturing: self.onClickStart() elif event_type == "blur": if self.isFocusing: self.isFocusing = False self.onClickCancel() elif event_type == "losecapture": if self.isCapturing: self.isCapturing = False self.onClickCancel() ButtonBase.onBrowserEvent(self, event) # Synthesize clicks based on keyboard events AFTER the normal # key handling. if (DOM.eventGetTypeInt(event) & Event.KEYEVENTS) == 0: return keyCode = DOM.eventGetKeyCode(event) if event_type == "keydown": if keyCode == ' ': self.isFocusing = True self.onClickStart() elif event_type == "keyup": if self.isFocusing and keyCode == ' ': self.isFocusing = False self.onClick() elif event_type == "keypress": if keyCode == '\n' or keyCode == '\r': self.onClickStart() self.onClick()
def onDoubleClick(self, sender=None): print 'name: ' + str(self.name) event = DOM.eventGetCurrentEvent() DOM.eventStopPropagation(event)
def onBrowserEvent(self, event): BooleanArgument.onBrowserEvent(self, event)#serve tb para controlar se pode ou nao encaixar if DOM.eventGetType(event) == "mousedown": if self._event_targets_btn(event): DOM.eventStopPropagation(event) MouseHandler.onBrowserEvent(self, event)