开发者

KeyEventArgs.Handled vs KeyEventArgs.SupressKeyPress

What's the difference between using

e.Handled = true

and

e.SuppressKeyPress = true

I've read that SuppressKeyPress calls e.Handled but els开发者_运维问答e does it do?


According to this blog: New keyboard APIs: KeyEventArgs.SuppressKeyPress:

The problem is that "Handled" doesn't take care of pending WM_CHAR messages already built up in the message queue - so setting Handled = true does not prevent a KeyPress from occurring.

In order not to break anyone who has currently got e.Handled = true, we needed to add a new property called SuppressKeyChar. If we went the other way, if "handling" a keydown suddenly started to actually work, we might break folks who accidentally had this set to true.


It simply prevents user input for all pending button hits. i.e. in a TextBox, not only event Handled is set to true, user input is suppressed and not reflected on the text box in case you're typing very fast and hit many buttons at once.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜