|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
space keysI'm writing a custom Text editor.
My idea was to override ProcessDialogKey to handle command keys, such as the arrow or delete and to override OnKeyPress to get char typed. Now I discover a few weird issues: - the space key don't trigger OnKeyPress - the backspace key does trigger OnKeyPress (with '\b') is it something normal (why is that) and stable (I could rely on next version to be like that as well)? I can't reproduce this. The standard textbox (correctly) generates KeyPress
for both space and backspace /claes Show quote "Lloyd Dupont" <net.galador@ld> wrote in message news:OQJIFfo5FHA.2576@TK2MSFTNGP09.phx.gbl... > I'm writing a custom Text editor. > My idea was to override ProcessDialogKey to handle command keys, such as the > arrow or delete > and to override OnKeyPress to get char typed. > > Now I discover a few weird issues: > - the space key don't trigger OnKeyPress > - the backspace key does trigger OnKeyPress (with '\b') > > is it something normal (why is that) and stable (I could rely on next > version to be like that as well)? > > I am overiding SWF.Control (not SWF.TextBox).
I also have these various set style set: SetStyle(ControlStyles.Opaque, true); SetStyle(ControlStyles.AllPaintingInWmPaint, true); SetStyle(ControlStyles.ContainerControl, false); SetStyle(ControlStyles.StandardClick, true); SetStyle(ControlStyles.StandardDoubleClick, true); SetStyle(ControlStyles.SupportsTransparentBackColor, false); SetStyle(ControlStyles.UserPaint, true); SetStyle(ControlStyles.UseTextForAccessibility, true); SetStyle(ControlStyles.OptimizedDoubleBuffer, true); SetStyle(ControlStyles.ResizeRedraw, true); SetStyle(ControlStyles.Selectable, true); SetStyle(ControlStyles.UserMouse, true); And my code is very simple indeed: protected override void OnKeyPress(KeyPressEventArgs e) { base.OnKeyPress(e); /// do something // space don't come here } Truth to tell I override ProcessDialogKey, but I do nothing and return base.ProcessDialogKeys() on SPACE Show quote "Claes Bergefall" <claes.bergefall@nospam.com> wrote in message news:%235a3%23Xr5FHA.2524@TK2MSFTNGP10.phx.gbl... >I can't reproduce this. The standard textbox (correctly) generates KeyPress > for > both space and backspace > > /claes > > "Lloyd Dupont" <net.galador@ld> wrote in message > news:OQJIFfo5FHA.2576@TK2MSFTNGP09.phx.gbl... >> I'm writing a custom Text editor. >> My idea was to override ProcessDialogKey to handle command keys, such as > the >> arrow or delete >> and to override OnKeyPress to get char typed. >> >> Now I discover a few weird issues: >> - the space key don't trigger OnKeyPress >> - the backspace key does trigger OnKeyPress (with '\b') >> >> is it something normal (why is that) and stable (I could rely on next >> version to be like that as well)? >> >> > > Hi,
Can you show us the code you're using to override the ProcessDialogKey function? -Altaf -------------------------------------------------------------------------------- All that glitters has a high refractive index. www.mendhak.com Show quote "Lloyd Dupont" <net.galador@ld> wrote in message news:OQJIFfo5FHA.2576@TK2MSFTNGP09.phx.gbl... > I'm writing a custom Text editor. > My idea was to override ProcessDialogKey to handle command keys, such as > the arrow or delete > and to override OnKeyPress to get char typed. > > Now I discover a few weird issues: > - the space key don't trigger OnKeyPress > - the backspace key does trigger OnKeyPress (with '\b') > > is it something normal (why is that) and stable (I could rely on next > version to be like that as well)? > If you create your own text editor you can override the ProcessCmdKey of the
control to have maximize control over all characters pressed private const int WM_KEYDOWN = 0x100; private const int WM_SYSKEYDOWN = 0x104; protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { if (msg.Msg == WM_KEYDOWN || msg.Msg == WM_SYSKEYDOWN) { switch (keyData) { case Keys.Control | Keys.A: // Do some action on key combination Ctrl + A { Console.WriteLine("Control + A"); break; } default: { Console.WriteLine(keyData.ToString()); break; } } } return base.ProcessCmdKey(ref msg, keyData); } Gabriel Lozano-Morán MCSD .NET Real Software I do just that for control keys such as Arrows, backspace, up/down, etc...
But I need OnKeyPress for text entering as the argument is a unicode char I assume it does the complex imput stuff which transform whatever key the user input to the expected international unichar (european acent, thai, chineese, arabic, etc..). Show quote "Gabriel Lozano-Morán" <gabriel.lozano@no-spam-thx.org> wrote in message news:%23RXGFou5FHA.1864@TK2MSFTNGP12.phx.gbl... > If you create your own text editor you can override the ProcessCmdKey of > the control to have maximize control over all characters pressed > > private const int WM_KEYDOWN = 0x100; > private const int WM_SYSKEYDOWN = 0x104; > > protected override bool ProcessCmdKey(ref Message msg, Keys > keyData) > { > if (msg.Msg == WM_KEYDOWN || msg.Msg == WM_SYSKEYDOWN) > { > switch (keyData) > { > case Keys.Control | Keys.A: // Do some action on key > combination Ctrl + A > { > Console.WriteLine("Control + A"); > break; > } > default: > { > Console.WriteLine(keyData.ToString()); > break; > } > } > } > > return base.ProcessCmdKey(ref msg, keyData); > } > > > Gabriel Lozano-Morán > MCSD .NET > Real Software > found it.
for some reason base.ProcessDialogKeys(keyData) was returning true. I just don't call base.ProcessDialogKeys() anymore. Could that be a problem? Show quote "Lloyd Dupont" <net.galador@ld> wrote in message news:OQJIFfo5FHA.2576@TK2MSFTNGP09.phx.gbl... > I'm writing a custom Text editor. > My idea was to override ProcessDialogKey to handle command keys, such as > the arrow or delete > and to override OnKeyPress to get char typed. > > Now I discover a few weird issues: > - the space key don't trigger OnKeyPress > - the backspace key does trigger OnKeyPress (with '\b') > > is it something normal (why is that) and stable (I could rely on next > version to be like that as well)? > |
|||||||||||||||||||||||