Set IsDefault property to button in XAML/C# WinRT app - windows-runtime

WPF XAML apps have had an IsDefault property for buttons so the Enter key will click a particular button by default. How can we do this in a Windows Run Time application?
<Button Name="SubmitButton" Content="Enter" />

You'll need to generate this yourself unfortunately, there is no built in property. Subscribe to the keydown event on the parent control and listen for the enter key to be hit, then execute your event.
if (e.Key == Windows.System.VirtualKey.Enter)
{
}

Related

Chrome Extension: Network Panel - Need to disable default question mark triggering help behavior

I am developing a Chrome extension that adds a custom devtools panel. My panel has some text boxes that allow user input, but any time I type a question mark, it opens Chrome help instead of tying the '?' character. Is there a way to stop this behavior?
UPDATE:
I should have mentioned that I'm using React in my extension and that I was using React's synthetic events.
This turned out to be unrelated to Chrome and due to a React JS nuance.
I was trying to call event.stopPropagation() on a React synthetic event which doesn't actually stop propagation to non-react registered event handlers such as the one that opens the help dialog.
The fix was to register a keydown event to the native DOM element and calling stopPropagation on the native event. This properly stoped the help menu from opening in response to typing in my input.
e.g.
<input
ref={input => input.addEventListener(event => event.stopPropagation())}
onChange={this.myOnChangeHandler}
/>

How to automatically enable a button

I have a button in a JSP which gets disabled after the first click. This is just to prevent multiple form submission at the same time. I want to enable the button once the form is submitted. My current logic keeps the button enabled and it seems like it bypass the disable property.
Without this.disabled = false button works perfectly fine by keeping the button disabled but I also want it to be enabled once the process is finished.
<input type="submit" class="esignReports" value="Export E-Sign Information" title="This function will provide you a 30 day download of all your eSign transactions." onclick="this.disabled=true;this.value='Please wait...';document.getElementById('viewIntegrationReport').submit();this.disabled = false">
Is there anyway to do it without JS
Thanks,
I think your button actually gets disabled but it gets re-enabled automatically because the submit is async, so you don't have enough time to see it's 'disabled' state. You could put console.log(this.state) before and after the submit() call to be sure.
There's no way to get a callback on submit() calls using plain Javascript (since it is supposed to send the info and reload the page). You'll need to use jQuery if you want to re-enable the button, using callbacks.

Detecting earphone button press

I am developing a VOIP app based on the VoipChatterbox sample app project and I need to manipulate the headset button click.
I see that, during an active call, when I press the button on the earphone, I get a CallEndRequested event and I need to call NotifyCallEnded within 5 seconds.
But I need a different behavior for my app. I need to simply turn the microphone off / on (toggle behavior) when the user presses the headset button. (This requirement might seem odd, but that's what make sense in the context of my application). How can I achieve this behavior?
To summarize :
Is there any other event to understand that user has pressed the earphone button?
Is there a way to override the behavior that NotifyCallEnded should be called in five seconds when CallEndRequested event is fired?

start application on alarm fires in windows phone 8

I am new to Windows Phone 8 application development and I am creating an application for setting alarm. I have created it and scheduled some alarms . It shows default alarm window with "Dismiss" and "Snooze" buttons. Can I have the provision to override the dismiss and snooze button events from my application. Or can I start my application which set the alarm when the alarm fires? Is anybody knows the answer please help me.
I guess there is no such way to override these buttons for an alarm. But if you are going to use a reminder then you will be able specify a relative navigation URI, and when an user taps on the reminder pop up you could redirect the user to your app.
For more refer here
http://www.geekchamp.com/articles/getting-started-with-windows-phone-alarms
Hope it helps!
You can not Override that butttons but you can have events that are fired when alarm popup opens or dismissed.
Inside your App.Xaml.cs, you can subscribe to the Obscured and Unobscured events of your RootFrame.
RootFrame.Obscured += new EventHandler<ObscuredEventArgs>(RootFrame_Obscured);
RootFrame.Unobscured += new EventHandler(RootFrame_Unobscured);
When the alarm pops up, RootFrame_Unobscured will be fired; after you dismiss it, RootFrame_Obscured will be fired.

Chrome Userscript (Greasemonkey) - Stop Gmail from sending an email

I am writing a Chrome Userscript (Greasemonkey) extension to display a confirmation dialog when the user clicks on Gmail's Send button (in the compose window etc.).
I have manged to attach to the click even of the button and show a dialog when the button is clicked, by using:
addEventListener("click", function(e) { ......... }, true);
But I cannot stop the email from being sent. I have tried using:
e.stopPropagation();
e.preventDefault();
return false;
How can I stop Gmail from sending the email?
I think that those mentioned by you can prevent default action that is built-in in browser, and stop propagation of event to parent elements in DOM hierarchy. You probably need to get the Gmail's event listener and do something with it - wrap it with your function (so, remove original event listener and bind your function, which displays a dialog and then invoke Gmail's one). Currently, when you only add an event listener, there are two independent event handlers.
Those posts might be useful:
How to find event listeners on a DOM node?
How to check if any JavaScript event listeners/handlers attached to an element/document?