Click to See Complete Forum and Search --> : disabling natural shortcuts within texbox derived class


^Johnny2Bad
June 24th, 2007, 05:24 AM
Hi,
First off I am using Visual Studio 2005 .net 3.0. I am trying my best too keep to .net 2.0 technology which in this particular case is fine.

I created a "compisite" tool I believe its called called dataBox which is directly derived from textbox. Anyhow I have made a context menu too perform such tasks as Paste, Copy etc. However I have noticed that the keyboard short cuts such as ctrl+v (paste) still work even though I may have paste disabled in my context menu. It appears it is still using the shortcut for the normal textbox paste etc.

Is there a way too disable the textbox generic menu shortcuts, if so how?

Thanking you in advance,
Jonathan.

^Johnny2Bad
June 26th, 2007, 10:04 AM
Okay as I believe I have found the resolution to this problem I might as well share it.

The mistake I was making was the enabling/disabling of particular menuitems was done through the Menu down event. So if I attempted to paste using the shortcut (Ctrl+v) it would assume it was okay because the verification process had not been completed.

So in order to get around this on the KeyDown event I added some code to call the verifier should any of the modifier keys be presssed (ctrl/shift/alt). This is turn disables/enables the specific menu commands and prevents erroneous cuts/pastes etc.

Cheers,
Jonathan