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


Python DOM.eventGetKeyCode方法代码示例

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


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

示例1: onBrowserEvent

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import eventGetKeyCode [as 别名]
    def onBrowserEvent(self, event):
        etype = DOM.eventGetType(event)

        if etype == "click":
            e = DOM.eventGetTarget(event)
            if not self.shouldTreeDelegateFocusToElement(e) and \
                            self.curSelection is not None:
                self.setFocus(True)
        elif etype in MouseListener.MOUSE_EVENTS:
            if etype == "mousedown":
                self.elementClicked(self.root, DOM.eventGetTarget(event))
            MouseListener.fireMouseEvent(self.mouseListeners, self, event)
        elif etype == "blur" or etype == "focus":
            FocusListener.fireFocusEvent(self.focusListeners, self, event)
        elif etype == "keydown":
            if self.curSelection is None:
                if self.root.getChildCount() > 0:
                    self.onSelection(self.root.getChild(0), True)
                Widget.onBrowserEvent(self, event)
                return

            if self.lastEventType == "keydown":
                return

            keycode = DOM.eventGetKeyCode(event)
            if keycode == KeyboardListener.KEY_UP:
                self.moveSelectionUp(self.curSelection, True)
                DOM.eventPreventDefault(event)
            elif keycode == KeyboardListener.KEY_DOWN:
                self.moveSelectionDown(self.curSelection, True)
                DOM.eventPreventDefault(event)
            elif keycode == KeyboardListener.KEY_LEFT:
                if self.curSelection.getState():
                    self.curSelection.setState(False)
                DOM.eventPreventDefault(event)
            elif keycode == KeyboardListener.KEY_RIGHT:
                if not self.curSelection.getState():
                    self.curSelection.setState(True)
                DOM.eventPreventDefault(event)
        elif etype == "keyup":
            if DOM.eventGetKeyCode(event) == KeyboardListener.KEY_TAB:
                chain = []
                self.collectElementChain(chain, self.getElement(),
                                         DOM.eventGetTarget(event))
                item = self.findItemByChain(chain, 0, self.root)
                if item != self.getSelectedItem():
                    self.setSelectedItem(item, True)
        elif etype == "keypress":
            KeyboardListener.fireKeyboardEvent(self.keyboardListeners,
                                               self, event)

        Widget.onBrowserEvent(self, event)
        self.lastEventType = etype
开发者ID:anandology,项目名称:pyjamas,代码行数:55,代码来源:Tree.py

示例2: onBrowserEvent

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import eventGetKeyCode [as 别名]
    def onBrowserEvent(self, event) :
        type = DOM.eventGetType(event)
        if type == "click":
            self.onClick(self)

        elif type == "keydown":
            modifiers = KeyboardListener.getKeyboardModifiers(event)
            if hasattr(self.keyDelegate, "onKeyDown"):
                self.keyDelegate.onKeyDown(self, DOM.eventGetKeyCode(event),
                                       modifiers)
开发者ID:Afey,项目名称:pyjs,代码行数:12,代码来源:ClickDelegatePanel.py

示例3: onEventPreview

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import eventGetKeyCode [as 别名]
 def onEventPreview(self, event):
     type = DOM.eventGetType(event)
     if type == "keydown":
         return (    self.onKeyDownPreview(
                         DOM.eventGetKeyCode(event),
                         KeyboardListener.getKeyboardModifiers(event)
                         )
                 and (not self.modal or self._event_targets_popup(event))
                )
     elif type == "keyup":
         return (    self.onKeyUpPreview(
                         DOM.eventGetKeyCode(event),
                         KeyboardListener.getKeyboardModifiers(event)
                         )
                 and (not self.modal or self._event_targets_popup(event))
                )
     elif type == "keypress":
         return (    self.onKeyPressPreview(
                         DOM.eventGetKeyCode(event),
                         KeyboardListener.getKeyboardModifiers(event)
                         )
                 and (not self.modal or self._event_targets_popup(event))
                )
     elif (   type == "mousedown"
           or type == "blur"
          ):
         if DOM.getCaptureElement() is not None:
             return True
         if self.autoHide and not self._event_targets_popup(event):
             self.hide(True)
             return True
     elif (   type == "mouseup"
           or type == "click"
           or type == "mousemove"
           or type == "dblclick"
          ):
         if DOM.getCaptureElement() is not None:
             return True
     return not self.modal or self._event_targets_popup(event)
开发者ID:FreakTheMighty,项目名称:pyjamas,代码行数:41,代码来源:PopupPanel.py

示例4: fireKeyboardEvent

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import eventGetKeyCode [as 别名]
def fireKeyboardEvent(listeners, sender, event):
    modifiers = getKeyboardModifiers(event)
    keycode = DOM.eventGetKeyCode(event)

    type = DOM.eventGetType(event)
    if type == "keydown":
        for listener in listeners:
            listener.onKeyDown(sender, keycode, modifiers)
    elif type == "keyup":
        for listener in listeners:
            listener.onKeyUp(sender, keycode, modifiers)
    elif type == "keypress":
        for listener in listeners:
            listener.onKeyPress(sender, keycode, modifiers)
开发者ID:certik,项目名称:pyjamas,代码行数:16,代码来源:KeyboardListener.py

示例5: onBrowserEvent

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import eventGetKeyCode [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()
开发者ID:Afey,项目名称:pyjs,代码行数:86,代码来源:CustomButton.py


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