开发者

Using SC.Timer to blink cursor

开发者 https://www.devze.com 2022-12-20 17:01 出处:网络
I\'m trying to have a cursor blink every 2.5 seconds but I\'m not sure how to use the SC.Timer object. The method I should be calling is _drawInsertionPoint(rect,context) every 2.5 seconds.

I'm trying to have a cursor blink every 2.5 seconds but I'm not sure how to use the SC.Timer object. The method I should be calling is _drawInsertionPoint(rect,context) every 2.5 seconds.

I found this:

var timer = SC.Timer.schedule({
target: this
action: '_drawInsertionPoint(rec,context)',
interval: 100,
repeats: YES,
until: Time.now() + 1000
}) ;

But I don't know how to pass in the parameters in action; it won't work.开发者_运维知识库

Any insight to this would be greatly appreciated.


You need to pass an anonymous function as the action parameter, like this:

var timer = SC.Timer.schedule({
    target: this
    action: function() { _drawInsertionPoint(rec,context); },
    interval: 100,
    repeats: YES,
    until: Time.now() + 1000
});
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号