I m using observables to handle keydown events. I d like to publish an observable, that will always set the key to handled iff the consumer has actually processed it. Is this possible?
这方面的一个例子是,我如何确定现在处理的关键:
KeyDown.Where(e => e.Key == Keys.W)
.Subscribe(e => { Console.WriteLine(e.Key); e.Handled = true; });
在此,我要举一个例子,说明我如何做(如果所处理的财产随后自动确定,我只能发表主旨,而不是关键人物:
HandledKeyDown.Where(k => k == Keys.W).Subscribe(k => Console.WriteLine(k));
Here s what I tried:
HandledKeyDown = Observable.Create<Key>(observer => {
var keys = KeyDown.Subscribe(e => { e.Handled = true; observer.OnNext(e.Key); });
return () => keys.Dispose();
});
该法典的问题是,无论消费者是否实际加工,钥匙总是按处理方式确定。
是否有办法知道该守则是否“符合”用户方法?