Is there any way to stop the default behaviour of an AG GRID cell on enter event ?
I tried e.preventDefault() nothing seems to stop it from exiting edit mode when I press enter, I'm trying to do a custom logic on press enter and it's not allowing me to!
After further looking, I found a function called supressKeyboardEvent it takes params as arguments and returns a boolean (Whether should the event be suppressed or not).
For more details refer to this official Ag grid source : https://www.ag-grid.com/javascript-data-grid/keyboard-navigation/#suppress-keyboard-events
Related
I'm looking for a way to post a MudForm upon pressing Enter from any control inside the form, without checking each keyboardevent argument and filtering for Enter, and without binding the listener to each form control in every MudForm.
The goal is to post any MudForm across my project by pressing Enter as a default behavior.
I want to set focus on a button while caret is present in textbox and user can still enter data to textbox. But when user presses enter key, button press will be simulated.
I am currently using a work around to solve this problem by handling onKeyDown event and checking for enter key. But problem is there is no clue for user to understand this as there is not blue border around the button that indicates focus on button.
Here is a example of what I want to implement (user can enter text in textbox while focus is on :
I have tried to search on google and StackOverflow but could not find any relevant result.
This is a fundamental Windows principle. It's not possible to have 2 controls (windows) focused at the same time.
So the focus should be inside the text box. But you can get the visual indication needed by setting the ok button as AcceptButton of the form (you might also want to set cancel button as CancelButton).
In the form constructor, load event or using designer:
this.AcceptButton = okButton;
There is no need to handle KeyDown event - as soon as the text box is not multiline, pressing Enter while the focus is inside it will generate ok button click. The same applies for the button set as CancelButton when you press ESC.
I have a form designed with the GUI designer with input textfields and buttons. I have attached actions to the buttons. When I call up the form with showForm(Form,null), the textfields are not accepting input and the buttons are not triggering the action. This is happening only for this form. Initially, there was the problem solved here Unable to call a specific form from a button in codenameone and then the problem solved here Simulator keeps defaulting to old Main form. What could be the issue now?
As far as I know there may be some issues as you say, but first need to see code
In the form after you added the text fields did you select the text field component and press action event?
Assuming you did that you should get a callback method in the Statemachine class.
This call will be invoked only when the user changes the content of the text field. You can run in the debugger and set breakpoints/step into code to see what is going on.
For a certain inputform, I'd like to make it possible to do input with the keyboard. I know how to read the keys through KeyPressed and KeyUp, but the problem is that when a control has got the focus and the user presses the Enter key, that control receives the a Click event. Is it possible to prevent that behaviour ? Or is it possible to know if a Click Event was fired by the mouse or by the keyboard ?
Does this help? From Microsoft Knowledge Base
Move the Button's code from the button.Click() to a button.MouseClick()
This would be easier if you could describe the situation and exact behaviour you want... :)
You can set:
Form.KeyPreview = True
This sends Key Events to the Form first, and then to the Control. This gives you the opportunity to catch Key Events on the form and 'cancel' them:
e.Handled = True
More info
Also make sure you haven't set the AcceptButton for the Form!
You can also listen for keyboard events and filter out keys.
I have a form with a default OK button, and a Cancel button. I have a treeview with nodes that can be edited, i.e. you can double-click them or press F2 to open another form.
Now, I've never liked that F2 shortcut, and now that I'm enabling treeview label edition, it's even worse. My first reaction when testing the form was to press "Enter" to edit the selected node, but doing this would go against the normal default button behavior.
Your opinion: Should an application always enforce the default button being triggered with the Enter key? If so what kind of shortcut should an application use to "edit the selected item"?
Definitely not... Confuses our users no end that enter doesn't select what they have highlighted.
Absolutely no. The Enter key is often used to fire the default button but equally often not. For example, Enter generally means new line in a multiline textbox.
Enter sounds like a good bet in this scenario. F2 tends to mean "Edit" in Windows.
However, if this is a long-standing application you may just irritate users who are used to F2.