space keys

  • Thread starter Thread starter Lloyd Dupont
  • Start date Start date
L

Lloyd Dupont

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 can't reproduce this. The standard textbox (correctly) generates KeyPress
for
both space and backspace

/claes
 
Hi,

Can you show us the code you're using to override the ProcessDialogKey
function?

-Altaf
 
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 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
 
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..).
 
found it.
for some reason base.ProcessDialogKeys(keyData) was returning true.
I just don't call base.ProcessDialogKeys() anymore.

Could that be a problem?
 
Back
Top