confirm messagebox only with mouse - c#

I wrote an application, where the user filled in a form with some text and pressed enter when a textbox is filled. After this some checks were done and a nominal MessageBos with an OK-Button appeared. Some useres didn't read the messagebox, typed in as there were in the next textbox, pressed the OK-Button and the warning/error-message disappeared without reading.
I know, I cannot to control, that the user really read the message, but I want, that the usere use the mouse for conforming. Is there a way, that the Ok-button doesn't have the focus when the messagebox is shown ? Or do I have to write my Own Messagebox with an extra field, that has the focus.

While protecting users from themselves is typically a no-win endeavor, I would suggest that to do what you want would require you to construct a form of your own in which you could capture the keyboard input and disallow the dismissal of the dialog when the Enter key is pressed.

Related

How to get the "Return" key from the Android TouchScreenKeyboard (Unity, C#)

I have an InputField component that once I press my physical keyboard key Return the text in the InputField is saved. I want the same thing to happen when pressing my Android TouchScreenKeyboard "OK" or "Done" (I also tested with keyCode.Enter and that does not work). Do you know a specific KeyCode for it? Or maybe another way to achieve this?
This is the code that works with my physical keyboard:
if(Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.KeypadEnter))
{
doThis(); //Saving the input's text to a variable
}
I want the same result when pressing "OK" or "Done" in my Android's TouchKeyboard. When pressing the mentioned choices, the TouchKeyboard gets hidden but the data in the InputField doesn't submit. I have created an on-screen button that calls the function doThis() as a workaround, but I want to avoid this.
Subscribe to InputField's onEndEdit event, its quite reliable at firing whenever the user is done entering text, weather its pressing enter or just loosing focus of that window, it gets fired when the user is done typing, I believe it should solve your issue
this works fine for me (PC/Mobile), try it out
this.yourInput.onSubmit.AddListener(delegate {
if (this.yourInput.text.Length > 0)
//do something when enter or done (mobile)
});

pressing the enter key on ok button of message box causes a repetitive message box

I have an application developed using mvvm framework.
I have a textbox with validation to enter only characters otherwise display a message box.
once the message box with ok button is displayed, user clicks on enter key when the focus is on ok button of message box. on enter click message box pops up repeatedly. once the enter key is pressed the message box should not popup again.
How to solve this issue.
are you clearing the offensive text out of the text box? or is it coming back after the ok to see the offending text and infinitely respond before it can be manually cleared? can you explain more about the problem if this isnt a fix?

want to stop user input by messagebox but bypassed by a Enter keydown

I'm coding a windows form application running on a barcode scanner.
The plantform is .Net2.0CF/C#.
What i want is whenever user input wrong, the app will pop a messagebox and block the next input(actually,a scan action) until user click the OK on the screen.
But normally the user will continuously scan the next stuff as they didn't find anything went wrong, this will insert a Enter keydown so the messagebox will be closed, in one word, the messagebox does not stop the user.
How can i code this? Below is a very simple code snippet
private void tb_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode.ToString() == "Return")
{
if(!ValidateInput(tb.Text))
MessageBox.Show("Error");
}
}
You can create your own window (Form) that displays the error message, but does not react on the enter key.
It should contain a button which the user can click (as you wrote), however you need to make sure the button does not have focus when the window is displayed. (Because if it had focus, pressing the return key will "click" the button.)
A simple way for doing this is adding another control which has TabStop set to true (e.g. a textbox, another button) and which has a lower TabIndex property than the button.
Additionally, maybe you might want to do a
System.Media.SystemSounds.Beep.Play();
when showing the window to draw the user's attention to the window.

Virtual keyboard in my form. Preventing button focus

I'm trying to create a virtual NumPad in my form. When the user clicks any of the numpad buttons, the corresponding number should be sent to the currently focused TextBox (or any other text control).
Simulating keystrokes aside, how can I prevent the numpad button, which is inside a numpad control, from stealing focus from the already focused TextBox?
I've tried googling and searching SO but didn't find anything that helped me.
Add this line in click event of Numpad button.
this.ActiveControl = YourTextboxID;
SetStyle(ControlStyles.Selectable, false);

In Gtk, can I make a Button's mnemonic not require an "alt" mask?

I have 6 Buttons, labeled "_0" through "_5". I would like for each button to be pressed when the user presses the corresponding number key. Right now, they must press Alt + the corresponding number key.
I can sort of work around this by giving each button an Accelerator, but it's not quite the same thing. With accelerators, as soon as the key is pressed, the button's Clicked signal is triggered. With mnemonics, the button becomes depressed when the key is pressed, and the Clicked signal isn't triggered until the button is released. I prefer this, because it helps the user to see what is happening.
Is there any way I can get the behavior of Mnemonics, but without requiring the Alt key?
You can have the gtk window catch key events with the event mask settings in the window class. I can't be much more specific than that with callbacks and key types, because I use GTKmm (C++ bindings) but the approach should be similar. Basically when you catch the required key event in your window you can call the button press in code. The window has be to selected (in focus) however.

Categories

Resources