How to detect when button pressed and released on android

Use OnTouchListener instead of OnClickListener: // this goes somewhere in your class: long lastDown; long lastDuration; … // this goes wherever you setup your button listener: button.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if(event.getAction() == MotionEvent.ACTION_DOWN) { lastDown = System.currentTimeMillis(); } else if (event.getAction() == MotionEvent.ACTION_UP) { lastDuration = System.currentTimeMillis() – … Read more

Capture button release in Android

You should set an OnTouchListener on your button. button.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if(event.getAction() == MotionEvent.ACTION_DOWN) { increaseSize(); } else if (event.getAction() == MotionEvent.ACTION_UP) { resetSize(); } } };

WPF – How to create image button with template

You won’t need dependency properties because you are inheriting from Button. You already have the IsPressed and IsEnabled properties. In fact, this is all you need: <Button x:Class=”TestWpfApplication.ThreeStateImageButton” xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation” xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml”> <Button.Template> <ControlTemplate TargetType=”{x:Type Button}”> <Grid> <Image Name=”Normal” Source=”Resources/Normal.png”/> <Image Name=”Pressed” Source=”Resources/Pressed.png” Visibility=”Hidden”/> <Image Name=”Disabled” Source=”Resources/Disabled.png” Visibility=”Hidden”/> </Grid> <ControlTemplate.Triggers> <Trigger Property=”IsPressed” Value=”True”> <Setter TargetName=”Normal” Property=”Visibility” Value=”Hidden”/> … Read more

How do I get Greasemonkey to click on a button that only appears after a delay?

That code has errors. Use Firefox’s error console (CtrlShiftJ) to see them. Using jslint to check your code, can be helpful too. Anyway, this is a common Greasemonkey problem. Use the waitForKeyElements() utility to handle the delayed appearance of that button. Use jQuery to simplify the code (and make it more robust and portable). So … Read more

wpf custom button best approach

Like you, when I was getting started and wanted to understand how / what was going on and working with templates, it took a lot of trial and error. Hopefully my research and some step-by-step components can help you customize to your liking and KNOWING where things are coming from. First, when trying to understand … Read more

How do you click a button in a webbrowser control?

webBrowser1.Navigate(“http://www.google.com”); If you have an ID use this: webBrowser1.Document.GetElementById(“id”).InvokeMember(“click”); If you have TagName use this webBrowser1.Navigate(“http://www.google.com”); In Web Browser DocumentCompleted event HtmlElement textElement = webBrowser1.Document.All.GetElementsByName(“q”)[0]; textElement.SetAttribute(“value”, “your text to search”); HtmlElement btnElement = webBrowser1.Document.All.GetElementsByName(“btnG”)[0]; btnElement.InvokeMember(“click”); If you have name Class use this: HtmlElementCollection classButton = webBrowser1.Document.All; foreach (HtmlElement element in classButton) { if (element.GetAttribute(“className”) == … Read more

Add a JavaScript button using Greasemonkey or Tampermonkey?

Ok, here’s a complete script that adds a live button to SO question pages1: // ==UserScript== // @name _Adding a live button // @description Adds live example button, with styling. // @match *://stackoverflow.com/questions/* // @match *://YOUR_SERVER.COM/YOUR_PATH/* // @grant GM_addStyle // ==/UserScript== /*— Create a button in a container div. It will be styled and positioned … Read more

How can I hide/show a div when a button is clicked?

Use JQuery. You need to set-up a click event on your button which will toggle the visibility of your wizard div. $(‘#btn’).click(function() { $(‘#wizard’).toggle(); }); Refer to the JQuery website for more information. This can also be done without JQuery. Using only standard JavaScript: <script type=”text/javascript”> function toggle_visibility(id) { var e = document.getElementById(id); if(e.style.display == … Read more