Button Command only get invokes when pressing the second time - windows-phone-8.1

I have a Button on my windows phone application. I have the Command Button binds to my RelayCommand in my ViewModel:
<Button Command="{Binding DoSomethingCommand}" CommandParameter="aString"/>
I see DoSomethingCommand get invoked correctly when I press the Button.
But when the keyboard is launched, I need to click the button twice before I see the DoSomethingCommand get invoked. The first click causes the keyboard to close, the second click invokes DoSomethingCommand.
Can you please tell me why there is a change in behaviors when the keyboard is open or not?

I came across the same issue today.
To explain it a bit better: a text box is focused, the keyboard is visible and a button is below the text box. Tapping this button the first time, unfocuses the text box and closes the keyboard. Tapping the button a second time, triggers the tapped event.
To solve this, I set MyTextBox.IsEnabled to false and then back to true in the next line. Setting it to false, unfocuses it. Setting it to true again, makes it usable again. The user won't notice, the keyboard closes and the button is tappable the first time.
Alternatively, one can set the focus to the button after leaving text box focus.

Related

Button on form looks like it is being constantly pressed after being clicked

I have a form in Access 2013 that uses a button to jump to another form.
However when the button is clicked certain requirements have to be met in order for the jump process to actually be executed. If the requirements are not met the user is forced to stay on the current form (with the button).
When this happens the button stays in the clicked (i.e. pressed down) state on the form, making it look like it's being constantly pressed.
(Note: If the button is clicked again and the requirements again aren't met it pops back out...)
Is there any way to change the appearance of the button back to the unclicked appearance after every click when the user is forced to stay on the current form?
Many thanks in advance for any kind of help!
A regular button can stay depressed for a short while, while its _Click() event procedure is running.
But once that finishes, it always returns to its normal state.
So the assumption was, that a toggle button was used instead, which turned out to be correct.

Windows Store: textbox inside flipview, cannot dismiss SIP keyboard when lost focus

I am using a full-screen flipview to allow a background to rotate behind a set of inputs. if you tap the input textbox, the SIP keyboard appears.
however, tapping outside of the textbox does not dismiss the keyboard as expected. I finally realized it is because of the flipview. I verified this by adding a 250 margin around the flipview. if i tap in the area covered by the control it still doesn't dismiss, but if I tap the areas covered by the margins (that is, outside the flipview) the SIP does dismiss as expected.
I tried setting IsTabStop to false and IsTapEnabled to false for the flipview, but the SIP still remains active unless i tap outside the flipview.
since we need the flipview to be full screen, I need to know if there is a way to disable the control so that it closes the keyboard.
can this be done? which property or event on the flipview can I leverage to make this happen?
aha, by handling the "tapped" event I did the old trick of disabling and enabling the flipview and sure enough the keyboard dismissed!

WinRT stop control having focus on load

When my app starts the first textbox has focus. This doesn't really matter when running on a desktop, but when it runs on a tablet it means the onscreen keyboard pops up and obscures half the screen.
How can I prevent any control having focus when the app first starts?
Place a button on your page with an earlier TabIndex:
<Button
IsHitTestVisible="False"
Opacity="0"
TabIndex="1" />
A few things to note:
Setting visibility to Collapsed doesn't work since the engine likes to focus the first Visible control
You need IsHitTestVisible="False" so users don't accidentally click it and it doesn't accidentally block clicks to anything else on the page.
Another control type could work, but it shouldn't be a TextBox since it would still bring up the virtual keyboard.
Setting IsTabStop="False" on your TextBox doesn't work since then it can't get focus at all.
I believe there is no way to simply remove focus other than setting IsTabStop to false on all controls, but the workaround might be to place an invisible control (e.g. UserControl with IsTabStop set to true and Opacity set to 0) with a lower tab index in your page.

html onfocus tab vs page load

Let's say I have an onFocus event for a text box. That event triggers when the user tabs into that box, as expected. But it also seems like the event triggers when the box is selected, and then the window is covered and then uncovered, by switching tabs, opening then closing another application, etc. Is there a way to make it so that the event triggers only by tabbing (or mouse-clicking) the text box, and NOT by covering then uncovering the window?
You can use an onClick event. This will only trigger the event on the click though, not tabbing.
You could also use onKeyDown which would trigger on any key press, but would also trigger when the user tabbed away from the textbox.
http://jsfiddle.net/kBzAu/2/
when one goes away from page, you may use window.document.onblur=function(){disable all onFocus};
and re activate them with window.document.onfocus=function(){enable all onFocus};

Swing- focus problem

In my application I have a frame, with toolbar (the toolbar contains some actions).
I want the toolbar to be visible only when the window is focused.
So, I registered a windowFocusListener on the window.
The problem is-
when the window is not focused and I click on the place where a tool bar action should be- the action is performed.
This happens because the WindowFocusGained is called before the mouse button is released and when the mouse button released it calls the actionPerformed.
Does anybody has any idea for a work around for this problem?
Does anybody know how to determine wether the mouse button is clicked now?
You could add a MouseListener to the window, and check if the toolbar is visible in the mousePressed event. If the toolbar is not visible at the time the mouse is pressed, set a flag on the toolbar (something like "ignoreNextAction").
In the toolbar, check that flag in your actionPerformed event handler.
Reset the toolbar flag in the mouseReleased event on the window, so that the next click will work correctly.
This is assuming the mouseReleased event on the window happens after the actionPerformed on the toolbar (not sure about this). Worst case, you can work with a timer which resets the flag 50ms after the mouse event.
You could now only hide the toolbar when the window loses focus, but also disable all buttons with setEnabled(false), then re-enable on focus gain. Alternatively, synchronize setEnabled(..) with the visibility of the buttons (instead of the window focus).