extjs Keydown for Tab back key press(Shift + Tab) - extjs

I have grid column key down event function I want to catch back Tab key press event
mycol.editor.addLissiner('keydown',keydownfunc(), this);
keydownfunc : function(txtField, e) {
var key = e.getKey();
if(key == Ext.EventObject.TAB){
alert('tab);
}
if(key == TAB+SHIFT){
alert('backtab');
}
}
I can catch Tab key press using key == Ext.EventObject.TAB but i can't catch back tab press key event. Please help tell what i do for catch back tab(shift+tab) event

Try checking 'Ext.EventObject.shiftKey' inside TAB key handler to determine shift key is pressed or not...

you can observe :
"http://jsfiddle.net/mohammad_erdin/sDFfY/"
this will surely help you.

Related

Catching Modifier-Keys in WPF ContextMenu

I would like to use the LeftAlt and RightAlt keys to alter MenuItems within an open ContextMenu. I want this all happen while the menu is already open - not while right mouse is clicked to open the context menu. I did the following:
ContextMenu.KeyDown += ContextMenu_KeyDown;
void ContextMenu_KeyDown(object sender, KeyEventArgs e)
{
if( e.Key == Key.LeftAlt || e.Key == Key.RightAlt )
{
e.Handled = true;
// DEMO
MenuItem firstItem = this.ContextMenu.Items[0] as MenuItem;
if( firstItem != null ) firstItem.Header = "Alt Pressed!";
}
}
Unfortunately this is not working. As soon as I press the Alt-Key the ContextMenu is closed although i use e.Handled = true;. Why is this? How can I catch the Alt-Keys and alter the context menu and leave the menu open?
According to this post (WPF: When Alt key is pressed, my ContextMenu won't open), it is a built-in behavior of the MenuBase class. You will need to choose another modifier key to accomplish this.
Here is the MSDN page explaining it : https://msdn.microsoft.com/en-us/library/system.windows.controls.primitives.menubase.onkeydown.aspx

In WPF, how do I handle modifier keys that are pressed after a key is held down in a KeyDown event?

I have a WPF window that I allow the user to move around by pressing the arrow keys. I've done this by hooking into the KeyDown event:
<Window ... KeyDown="Window_OnKeyDown">
One press of an arrow key will move the window 1 pixel. Obviously, this is pretty slow, so I also allow the user to hold the shift key to move the window around faster, 5 pixels at a time:
private void Window_OnKeyDown(object sender, KeyEventArgs e)
{
var key = e.Key;
var pixelAmount = e.KeyboardDevice.Modifiers == ModifierKeys.Shift ? 5 : 1;
switch (key)
{
case Key.Up:
Top = Top - pixelAmount;
break;
case Key.Down:
Top = Top + pixelAmount;
break;
case Key.Left:
Left = Left - pixelAmount;
break;
case Key.Right:
Left = Left + pixelAmount;
break;
}
}
This code works great if the user presses Shift followed by an arrow key. Problem is, this doesn't work if the user is holding down an arrow key first, then presses Shift to speed up the movement. This is because the Window_OnKeyDown() now thinks that Shift is the active key, and the switch statement is run against the Shift key rather than the already-pressed arrow key. Does anyone know how I can fix this behavior?
If the user presses the Shift key after the arrow key, e.Key will change to shift and hence this code will not work. Only solution I can think of is using
bool Shift = (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift))
and to get the arrow key also, you can use Keyboard.IsKeyDown(), example Keyboard.IsKeyDown(Key.Up)

How do I assign shortcut keys to buttons on the bindingNavigator?

Is there a way to assign shortcut keys to the standard navigation ToolStrip Items in a BindingNavigator?
The items that get added using the .AddStandardItems method are of type ToolStripItem which doesn't have a ShortcutKeys property.
I tried to cast to ToolStripMenuItem , but it fails.
public void ConfigureMyNavigator()
{
// Adds ToolStripItems which don't support shortcut keys
m_navigator.AddStandardItems();
// Adds a ToolStripMenuItem which can support a shortcut key
var button = new ToolStripMenuItem
{
Size = new Size(0, 0),
Text = "Save",
ShortcutKeys = (Keys)Shortcut.CtrlS,
ToolTipText = "Press Ctrl+S to save"
};
button.Click += tsmi_Click;
m_navigator.Items.Add(button);
// This fails with invalid cast exception
((ToolStripMenuItem)m_navigator.Items[1]).ShortcutKeys = (Keys)Shortcut.AltLeftArrow;
}
I guess I could replace the toolstripitems with toolstripmenuitems one by one, but feel this is rather awkward.
You can listen for key commands and then raise the click of the appropriate ToolStripButton. Override the ProcessCmdKey method in your form code:
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
switch (keyData)
{
case (Keys.Alt | Keys.Left):
m_navigator.Items[1].PerformClick();
break;
case (Keys.Alt | Keys.Right):
m_navigator.Items[6].PerformClick();
break;
}
return base.ProcessCmdKey(ref msg, keyData);
}
Did you try adding "&" symbol in front of the button caption?
Text = "&Save"
You can override the AddStandardItems method and overload the ToolStripMenuItem's constructor to accept ToolStripItem as a parameter for easier creation of the items.
But it's still sort of "replacing the items one by one".

cursor automatically move from one uitextfield to other textfield in ios?

I have 4 uitextfield controls if textfield length is 1 move to next uitextfield and hitting backspace delete one by one textfield text in reverse direction.
like ipad unlock passcode while startup.
You can use the UITextField delegate method to move to the next text field:
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
if (textField == textFieldA) {
[textField resignFirstResponder];
[textFieldB becomeFirstResponder];
} else if (textField == textFieldB) {
// etc...
}
return YES;
}
For the Delete or Backspace key you try something like this:
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
Other than that, I don't know of any other ways to catch keyboard events in iOS.

Prevent double click on a row divider triggering celldoubleclick event

In a datagridview with rowheaders visibility set to false and allowusertoresizerow set to true, i need to prevent the celldoubleclick event to trigger if doubleclicked on the rowdivider (Toublearrow of the row resize is visible when the cursor is on the divider).
Thanks
I guess the easiest way would be checking the clicked area of the grid on the CellDoubleClick event itself; the logic would be to return in case rowresizetop or rowresizebottom areas are clicked and continue processing if not. Please check an example below for more details:
private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
// get mouse coordinates
Point mousePoint = dataGridView1.PointToClient(Cursor.Position);
DataGridView.HitTestInfo hitTestInfo = dataGridView1.HitTest(mousePoint.X, mousePoint.Y);
// need to use reflection here to get access to the typeInternal field value which is declared as internal
FieldInfo fieldInfo = hitTestInfo.GetType().GetField("typeInternal",
BindingFlags.Instance | BindingFlags.NonPublic);
string value = fieldInfo.GetValue(hitTestInfo).ToString();
if (value.Equals("RowResizeTop") || value.Equals("RowResizeBottom"))
{
// one of resize areas is double clicked; stop processing here
return;
}
else
{
// continue normal processing of the cell double click event
}
}
hope this helps, regards

Resources