Hi,
For a long time I had the following bookmark in Firefox:
http://www.codeguru.com/csharp/.net/net_general/keyboard/article.php/c4639
I know decided to read it and implement it in the application it was supposed to be implemented some time ago. However, I don't see any benefit in such a method...
I know that the idea behind the hastable is provide a collection where we know for sure that there are no collisions, that every item is unique. But, is there really any big benefit in using an hashtable for keyboard accelerators?
For instance, what's the benefit in having this (as in the link above):
protected override bool ProcessCmdKey(ref Message msg, Keys keyData) {
Accelerators accel = Accelerators.Unspecified;
if (_accelHash.ContainsKey(AcceleratorKey(keyData))) {
accel = (Accelerators)_accelHash[key];
switch (accel) {
case Accelerators.Home:
DisplayHome();
return true;
}
}
return base.ProcessCmdKey(ref m, keyData);
}
Over this:
protected override bool ProcessCmdKey(ref Message msg, Keys keyData) {
switch (keyData) {
case Keys.Alt | Keys.H:
DisplayHome();
return true;
}
return base.ProcessCmdKey(ref m, keyData);
}