【问题标题】:custom signal into gtk app in javascript language用javascript语言自定义信号到gtk应用程序
【发布时间】:2014-09-04 14:35:15
【问题描述】:

尝试在使用 javascript 语言的 gtk 应用中从一个对象向另一个对象发送信号。

const pippo = new Lang.Class({
Name: "test.pippo",

_init: function () {
    Log('test init');

    this._start();
},

_start: function () {
    Log('signal emit');

    this.emit("pippo-start");

}
});

Signals.addSignalMethods(pippo.prototype);

这是我用来创建和绑定信号的方法:

var tmp =new Util.pippo();
tmp.connect('pippo-start', Lang.bind(this, function () {
  Log('event receive!!!');
}));

在日志中,我看到刚刚发出但从未被函数接收到的信号正在侦听; 有什么建议吗?或此主题的 javascript 文档?谢谢

【问题讨论】:

    标签: javascript signals gnome gobject gnome-shell


    【解决方案1】:

    看来你这里只有 Object.prototype。 以定义原型的方式声明你的类:

    function pippo() {
        this._init.apply(this, arguments);
    }
    
    /*
    * 
    */
    pippo.prototype = {
        _init: function () {
            Log('test init');
    
            this._start();
        },
    
        _start: function () {
            Log('signal emit');
    
            this.emit("pippo-start");
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-12
      相关资源
      最近更新 更多