zoukankan      html  css  js  c++  java
  • Hiero中的Events机制

    The hiero.core.events module allows you to register method callbacks to respond to events sent by Hiero. Hiero uses this for the callback mechanism to allow Python scripts to get notifications when interesting things happen. It also allows for the creation of custom event types and for sending custom events.

    译文:

    Hiero.core.events模块允许用户注册callbacks方法去响应Hiero运行中发生的事件,Hiero通过使用这个callbacks机制让python脚本能够在关联事件发生时收到通知。Hiero也允许用户自定义事件类生成自定义的事件。

     

    An event is an object which is passed to registered callbacks.

    译文:

    event实际上是一个被传递给已注册的callbacks的对象。Callbacks响应event的时候,event会作为一个对象传递给callbacks。

     

    If the event comes from Hiero itself (and is not a custom user registered event), it contains three attributes:

    译文:

    如果事件来源于Hiero自身,且不是用户自己注册事件,那么它会包含以下三个属性:

     

    1.    type - indicates the type of the EventType (e.g. kShowContextMenu) 类型

    2.    subtype - indicates the subtype of the EventType (e.g. kTimeline)    子类型

    3.    sender (generally a view, or action which triggered the event)       触发事件

     

    The type and subtype attributes indicate the type and subtype of the event, respectively. The sender is the object that sent the event, and varies by event type (and sometimes by subtype event).

    译文:

    Type及subtype都是包含了event类型,触发事件则是发出event的对象,类型不同,触发事件也不一而论。

     

    Note

    The subtype attribute can be None. This is the case if an event is sent without a subtype. Generally, the type and subtype are strings, usually from the EventType enumeration.

    译文:

    Subtype属性可以为空,这个因为发出的事件往往也是没有子类型。但一般来说,type和subtype都是字符串型,通常来自于eventype的清单。

     

    The most basic event callback takes the following form:

     

    def eventCallback(event):

      print "Event fired with type %s, subtype %s and sender %s" % (event.type, event.subtype, str(event.sender))

  • 相关阅读:
    【js类库AngularJs】学习angularJs的指令(包括常见表单验证,隐藏等功能)
    【js类库AngularJs】解决angular+springmvc的post提交问题
    【javascript类库】zepto和jquery的md5加密插件
    【转】Java Cipher类 DES算法(加密与解密)
    手机QQ访问时,html页面在QQ中自定义预览和自定义分享
    dos 删除文件夹 rd
    摆动效果
    【js类库Raphaël】使用raphael.js根据点坐标绘制平滑曲线
    更新html技术比较
    动态设置缩放比例和html字体大小
  • 原文地址:https://www.cnblogs.com/hksac/p/4867929.html
Copyright © 2011-2022 走看看