Event bubbling in forms?

M

mikepope

I apologize if this has already been covered; I might be using the wrong
terminology to search for this. In a Word macro, I am displaying a form. I
want the ESC key to be the equivalent to clicking Cancel. Probably there's an
easy way to do this -- ?

For now, I have created a KeyDown handler for the control that has the focus
by default (the OK button). I look for keycode=27. This works fine, as long
as the focus is on the control that raises the event. What I was hoping was
that there is a way to forward (bubble) events from individual controls to
the containing form.

The form class does have a KeyDown event, but I'm not seeing how this would
ever be raised, since a control on the form would always have focus and
therefore always eat the event -- ?

I am curious about the possibilities for a) event bubbling and b) why the
form supports keystroke events, even if there IS an easy way to equate ESC
with Cancel. But that's asking kind of a lot. :)
 
J

Jonathan West

mikepope said:
I apologize if this has already been covered; I might be using the wrong
terminology to search for this. In a Word macro, I am displaying a form. I
want the ESC key to be the equivalent to clicking Cancel. Probably there's
an
easy way to do this -- ?

Create a button called Cancel. Set the Cancel property of the button to
true.

By the way, if you have an OK or similar button, you can set its Default
property to True. Pressing Enter will then have have the same effect as
clicking the OK button.
 
M

mikepope

Thanks!

Jonathan West said:
Create a button called Cancel. Set the Cancel property of the button to
true.

By the way, if you have an OK or similar button, you can set its Default
property to True. Pressing Enter will then have have the same effect as
clicking the OK button.


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top