• Advertisement
Sign in to follow this  

[.net] scrollbar stealing keyboard input

This topic is 3359 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
Sign in to follow this  

  • Advertisement