在mousedown - Sencha ExtJs中存储变量的问题

Issue with storing a variable in mousedown - Sencha ExtJs

本文关键字:存储 变量 问题 ExtJs mousedown Sencha      更新时间:2023-09-26

我在组件类中传递所需变量时遇到问题。问题是当spinup被点击时,类被再次调用,current_cursor_position被设置回"未定义"。我还没有找到另一种方法来注册鼠标点击。似乎我有共享变量之间的一个真正的问题。你有什么推荐吗?

提前感谢,

代码片段:

    current_cursor_position: undefined, //global variable to hold the cursor position that is used when spinUp is click. Also is used to store mouse down position 
init{
        this.getView().addListener('spinup', this.spinnerUp, this);
        this.getView().addListener('spindown', this.spinnerDown, this);
        this.getView().mon(this.getView().getEl(), {
        mousedown: function(e) {
          this.current_cursor_position = //logic to find and store user current mouse click
        }
},
spinnerUp {
this.current_cursor_position = //recorded cursor position 
…
//logic to increment time
}
…

我用错了。mon

this. getview ().mon(this. getview ().getEl(), 'mousedown', myFunction,this)