Overriding IE's Predefined Shortcuts Like CTRL-B
CTRL-B is the de facto standard shortcut for making a selection bold in word processing applications. When trying to implement that into a BrowserTextControl based user control that is used in Internet Explorer, IE opens the Organize Favorites dialog. I admit that this might be confusing to the user. The technical part: If the command key is not a menu shortcut of the user control and the control has a parent (in the simplest case IE itself), the key is bubbled up to the parent's…

CTRL-B is the de facto standard shortcut for making a selection bold in word processing applications. When trying to implement that into a BrowserTextControl based user control that is used in Internet Explorer, IE opens the Organize Favorites dialog. I admit that this might be confusing to the user.
The technical part: If the command key is not a menu shortcut of the user control and the control has a parent (in the simplest case IE itself), the key is bubbled up to the parent's ProcessCmdKey method.
To overcome this 'feature' of Internet Explorer, it is not enough to handle the KeyPress or KeyDown events in TX Text Control. TX Text Control will never receive the messages from IE.
What we need to do is to override the ProcessCmdKey method to handle the keys directly. You simply need to add the following method to your user control in order to handle CTLR-B and CTRL-I.
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
Keys key = keyData & ~(Keys.Shift | Keys.Control);
switch (key)
{
case Keys.B:
if ((keyData & Keys.Control) != 0)
{
browserTextControl1.Selection.Bold = !browserTextControl1.Selection.Bold;
return true;
}
break;
case Keys.I:
if ((keyData & Keys.Control) != 0)
{
browserTextControl1.Selection.Italic = !browserTextControl1.Selection.Italic;
return true;
}
break;
}
return base.ProcessCmdKey(ref msg, keyData);
}
Related Posts
TX Text Control Security Wizard Available
In order to run the BrowserTextControl component in Internet Explorer, the .NET Framework security mechanism Code Access Security (CAS) must be adjusted. Our documentation describes how to adjust…
BrowserTextControlSampleVisual Studio
BrowserTextControl: Using Post-build Events in Visual Studio
When developing with TX Text Control Server for ASP.NET (incl. Windows Forms) and it's BrowserTextControl class, you might have learned that you need to clear the .NET download cache (dl3)…
BrowserTextControlServerTextControl
BrowserTextControl: Compressed File Transfer
The BrowserTextControl class allows developers to deploy true WYSIWYG word processing applications to the web. Using this .NET component, it is possible to load, modify and save fully featured MS…
Activating the BrowserTextControl Automatically
Since objects like Flash, ActiveX controls or .NET assemblies must be activated in Internet Explorer manually, you have to click on it to be able to use them. This is also valid for the…
ASP.NET: Getting the Client's .NET Version
To use TX Text Control Server for ASP.NET (incl. Windows Forms)'s BrowserTextControl in the Internet Explorer, the .NET Framework must be installed on client-side. A client-side control is…