Sign in to follow this  
EvilNando

[.net] scrollbar stealing keyboard input

Recommended Posts

I have placed a couple of scrollbars over a custom control, the problem is that these bars seems to receive focus constantly , stealing keyboard inputs for themselves. Is there a way to configure these controls so that they ignore focus events or keypresses? thanks

Share this post


Link to post
Share on other sites
If the problem is what I think it is, then you need to make sure that the control that is meant to receive the key presses indicates that it does. In WinForms, you'd override the IsInputKey method, like this:

protected override bool IsInputKey(Keys keyData) {
switch (keyData) {
case Keys.Up:
case Keys.Down:
case Keys.Left:
case Keys.Right:
return true;
default:
return base.IsInputKey(keyData);
}
}

That will ensure that the control receives events from the cursor keys and that they won't be sent to the scrollbars instead.

Share this post


Link to post
Share on other sites
thanks I did not think of that.

a quick solution that I've found was to set the small and large change field both to 0 , then again I am not handling inputs in a standard fashioned way so maybe that is why it is working now ..

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this