F
fd123456
Hi all!
In a Form's constructor, I add a KeyEvent handler :
this.KeyDown += new KeyEventHandler(myKeyDown);
And here is myKeyDown :
private void myKeyDown(object sender, KeyEventArgs e)
{
e.Handled=true;
MessageBox.Show(e.KeyCode.ToString());
}
The problem is that if the key pressed is the starpad's middle button
(which, weirdly, is caught as Select AND Return AND F23 by CF), the
event is not consumed, e is not handled, and the MessageBox is closed
because it thinks I'm still pressing Return.
This is a very basic repro, but on a larger scale, it means that you
can not have two successive forms both having the Return key as a
validation, because as soon as the first one calls the second one, the
second one gets validated as well.
Is there a way to consume that OK/Select/Return/F23/middle key event?
I've looked all around and couldn't find anything. Having a loop
waiting for the KeyUp event is not possible, because that event
doesn't get consumed either. And waiting for SP2/3/Whidbey/VS 2018 is
not an option . Has anyone found a workaround?
Thanks for sharing if you have.
Michel.
In a Form's constructor, I add a KeyEvent handler :
this.KeyDown += new KeyEventHandler(myKeyDown);
And here is myKeyDown :
private void myKeyDown(object sender, KeyEventArgs e)
{
e.Handled=true;
MessageBox.Show(e.KeyCode.ToString());
}
The problem is that if the key pressed is the starpad's middle button
(which, weirdly, is caught as Select AND Return AND F23 by CF), the
event is not consumed, e is not handled, and the MessageBox is closed
because it thinks I'm still pressing Return.
This is a very basic repro, but on a larger scale, it means that you
can not have two successive forms both having the Return key as a
validation, because as soon as the first one calls the second one, the
second one gets validated as well.
Is there a way to consume that OK/Select/Return/F23/middle key event?
I've looked all around and couldn't find anything. Having a loop
waiting for the KeyUp event is not possible, because that event
doesn't get consumed either. And waiting for SP2/3/Whidbey/VS 2018 is
not an option . Has anyone found a workaround?
Thanks for sharing if you have.
Michel.