开发者

Handling keypress events in Silverlight

My app needs to run in a security-restricted browser. Because of this, textbox input is blocked in Silverlight (but not in HTML). I need to intercept the keystrokes and put them in the textbox to override this feature.

When a key event is detected, it ret开发者_如何学Pythonurns the letters all in upper case. (Why??) I need to be able to convert a keypress to lower case but don't have access to the shift state in the KeyEventArgs. The PlatformKeyCode supposedly returns ascii (this is an English/US only app) but it doesn't detect the shift state and returns all lower-case keys in upper case. These textboxes are username and password input and are case-sensitive.

I'm having a hard time believing I can't do something as simple as get a username and password.

I have no control over the security settings of the IE browser as it runs in a separate desktop application that was written by another company. This website is designed to interface with that desktop software. The authors of the software have no idea why Silverlight text input doesn't work. The textboxes work fine in a normal browser.


Use the Keyboard.Modifiers value to determine if shift is pressed.

ModifierKeys keys = Keyboard.Modifiers;
bool shiftKey = (keys & ModifierKeys.Shift) != 0; 

This blog has additional information for this and other keys.

Note that the key press events tell you what key is pressed, not what character that key generates. There is a distinction between the two.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜