本文整理汇总了Python中pyjamas.DOM.eventGetButton方法的典型用法代码示例。如果您正苦于以下问题:Python DOM.eventGetButton方法的具体用法?Python DOM.eventGetButton怎么用?Python DOM.eventGetButton使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyjamas.DOM
的用法示例。
在下文中一共展示了DOM.eventGetButton方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: onMouseUp
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import eventGetButton [as 别名]
def onMouseUp(self, sender, x, y):
event = DOM.eventGetCurrentEvent()
eventButton = DOM.eventGetButton(event)
if eventButton == Event.BUTTON_LEFT:
remote = server.TickeryService()
id = remote.login(LoginRedirector(self))
if id < 0:
self.setWidget(0, 1, Label('oops: LoginPanel'))
示例2: onMouseDown
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import eventGetButton [as 别名]
def onMouseDown(self, sender, x, y):
self.dragWidget = sender
event = DOM.eventGetCurrentEvent()
self.mouseEvent = event
button = DOM.eventGetButton(event)
if button != Event.BUTTON_LEFT:
return
# x, y = eventCoordinates(event)
# self.origMouseX = x
# self.origMouseY = y
self.dragging = DRAGGING_NO_MOVEMENT_YET
self.drag_time = time.time()
self.dragDataStore = DragDataStore()
示例3: onBrowserEvent
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import eventGetButton [as 别名]
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()
示例4: onMouseMove
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import eventGetButton [as 别名]
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()