本文整理汇总了Python中pyjamas.DOM.eventPreventDefault方法的典型用法代码示例。如果您正苦于以下问题:Python DOM.eventPreventDefault方法的具体用法?Python DOM.eventPreventDefault怎么用?Python DOM.eventPreventDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyjamas.DOM
的用法示例。
在下文中一共展示了DOM.eventPreventDefault方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: onMouseMove
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import eventPreventDefault [as 别名]
def onMouseMove(self, sender, x, y):
event = DOM.eventGetCurrentEvent()
DOM.eventPreventDefault(event)
# mousing auto re-enables mouse-over hover feedback
if not self.theChild.getHoverTouchingEnabled():
self.theChild.setHoverTouchingEnabled(True)
self.theChild.update()
示例2: onDrop
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import eventPreventDefault [as 别名]
def onDrop(self, event):
dt = event.dataTransfer
item = dt.getData("Text")
data = json.decode(item)
if 'name' in data and 'age' in data:
age = data['age']
name = data['name']
self.removeStyleName('dragover')
if self.age_is_ok(age):
self.addStudent(name, age)
dt.dropEffect = 'copy'
self.addStyleName('flash')
def removeFlash(timer):
self.removeStyleName('flash')
Timer(250, notify=removeFlash)
else:
dt.dropEffect = 'none'
self.addMessage('student could not be added')
# setting dropEffect to 'none' should be sufficient to notify
# that the drop failed, but
# we need to cheat a bit for now...
# this is the only reason for parent id in data
item_parent_id = data['parent']
item_parent = self.parent.containerFromId(item_parent_id)
item_parent.addStyleName('drop_fail')
# prevent default allows onDragEnd to see the dropEffect we set here
DOM.eventPreventDefault(event)
示例3: action
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import eventPreventDefault [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)
示例4: onBrowserEvent
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import eventPreventDefault [as 别名]
def onBrowserEvent(self, event):
# farm out the event to convenience handlers.
# detect existence by checking for the listener lists of each
# type of handler. there's probably a better way to do this...
if hasattr(self, "_clickListeners"):
ClickHandler.onBrowserEvent(self, event)
if hasattr(self, "_keyboardListeners"):
KeyboardHandler.onBrowserEvent(self, event)
if hasattr(self, "_mouseListeners"):
MouseHandler.onBrowserEvent(self, event)
if hasattr(self, "_mouseWheelListeners"):
MouseWheelHandler.onBrowserEvent(self, event)
if hasattr(self, "_focusListeners"):
FocusHandler.onBrowserEvent(self, event)
if hasattr(self, "_dragListeners"):
DragHandler.onBrowserEvent(self, event)
if hasattr(self, "_dropListeners"):
DropHandler.onBrowserEvent(self, event)
if self.contextMenu is None:
return True
type = DOM.eventGetType(event)
if type == "contextmenu":
DOM.eventCancelBubble(event, True)
DOM.eventPreventDefault(event)
self.contextMenu.onContextMenu(self)
return False
return True
示例5: onBrowserEvent
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import eventPreventDefault [as 别名]
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)
示例6: onElementContextmenu
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import eventPreventDefault [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)
示例7: onBrowserEvent
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import eventPreventDefault [as 别名]
def onBrowserEvent(self, event):
etype = DOM.eventGetType(event)
if etype in MOUSE_EVENTS:
if self._mousePreventDefault:
DOM.eventPreventDefault(event)
return fireMouseEvent(self._mouseListeners, self, event)
return False
示例8: onMouseWheel
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import eventPreventDefault [as 别名]
def onMouseWheel(self, sender, x, y):
event = DOM.eventGetCurrentEvent()
DOM.eventPreventDefault(event)
if self.getCurve(self.SELECTION_CURVE).isVisible():
if event.isNorth():
self.zoomIn()
elif event.isSouth():
self.zoomOut()
示例9: onDragOver
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import eventPreventDefault [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)
示例10: onMouseDown
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import eventPreventDefault [as 别名]
def onMouseDown(self, sender, x, y):
# regardless of drag_enabled, onMouseDown must prevent
# default, in order to avoid losing focus.
DOM.eventPreventDefault(DOM.eventGetCurrentEvent());
if not self.drag_enabled:
return
self.dragging = True
DOM.setCapture(self.getElement())
self.moveControl(x + Window.getScrollLeft(), y + Window.getScrollTop())
示例11: onBrowserEvent
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import eventPreventDefault [as 别名]
def onBrowserEvent(self, event):
type = DOM.eventGetType(event)
if type == 'mousedown' or type == 'mouseup' or type == 'mousemove' or type == 'mouseover' or type == 'mouseout':
MouseListener.fireMouseEvent(self.mouseListeners, self, event)
# stop event falling through esp. for drag on image
DOM.eventPreventDefault(event)
else:
Hyperlink.onBrowserEvent(self, event)
示例12: onMouseUp
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import eventPreventDefault [as 别名]
def onMouseUp(self, sender, x, y):
event = DOM.eventGetCurrentEvent()
DOM.eventPreventDefault(event)
if self.selecting or self.moving:
self.p2.x = self.getXAxis().getMouseCoordinate()
self.p2.y = self.getYAxis().getMouseCoordinate()
self.updateCursor()
self.selecting = False
self.moving = False
示例13: onKeyPress
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import eventPreventDefault [as 别名]
def onKeyPress(self, sender, keycode, modifiers):
DOM.eventPreventDefault(DOM.eventGetCurrentEvent()) #not needed
if keycode == KeyboardListener.KEY_UP:
self.nextContest()
if keycode == KeyboardListener.KEY_DOWN:
self.nextContest()
if keycode == KeyboardListener.KEY_LEFT:
self.nextSelection()
if keycode == KeyboardListener.KEY_RIGHT:
self.nextSelection()
示例14: onEventPreview
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import eventPreventDefault [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)
示例15: onMouseDown
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import eventPreventDefault [as 别名]
def onMouseDown(self, sender, x, y):
# regardless of drag_enabled, onMouseDown must prevent
# default, in order to avoid losing focus.
self.setFocus(True)
DOM.eventPreventDefault(DOM.eventGetCurrentEvent())
if not self.drag_enabled:
return
self.dragging = True
GlassWidget.show(self)
self.moveControl(x + Window.getScrollLeft(), y + Window.getScrollTop(),
True)