event-handling

Initiate onclick faster than with document.onload

你离开我真会死。 提交于 2019-12-10 10:06:29
问题 I have html-pages with links where i want to attach a function to their onclick-event. One way to do it is of course: <a href="save.php" onclick="save(); return false;" rel="save">Save</a> But I know this is not the best practice. So instead I wait for window.onload, loop through the links and attach the save-function to the links with rel="save". The problem with this is that it waits until the whole page has finished loading which can be several seconds after the link is displayed and

How to keep DropDownList of AutoCompleteTextView opened after pressing the Back key?

北慕城南 提交于 2019-12-10 07:58:59
问题 i am using AutoCompleteTextView in my Activity and i need it's DropDownList to be shown all the time (it's the only View in Window), even after Back key press. I need to dismiss soft keyboard instead. I tried to override Activity's onBackPressed method, but it's not used at all, so BackPressed event is being handled somewhere "higher". So i tried to find out where, but AutoCompleteTextView has no onBackPressed method defined. Any advices? 回答1: You can create your custom AutoCompleteTextView

Is there a simple way to detect mouse or keyboard activity in Linux/Xorg/Qt4/Kde4?

左心房为你撑大大i 提交于 2019-12-10 06:15:10
问题 Is there a simple way to detect mouse or keyboard activity in Linux or Xorg or Qt4 or Kde4 environment? Obviously not only on a particular window but in the entire Xorg desktop. 回答1: You can use the XScreenSaver extension ( man Xss ). It can provide you with values into this struct using the function XScreenSaverQueryInfo : typedef struct { Window window; /∗ screen saver window */ int state; /∗ ScreenSaver{Off,On,Disabled} */ int kind; /∗ ScreenSaver{Blanked,Internal,External} */ unsigned

Adding event handler in main() for SerialPort

坚强是说给别人听的谎言 提交于 2019-12-10 05:13:39
问题 I try to subscribe a event handler to the data received event. Seems like I cant specify the event handler function name. I dont understand why myComPort.DataReceived += new SerialDataReceivedEventHandler(comPort_DataReceived); is giving me error message. Here is the problem, hope anyone can answer it. a busy cat http://img827.imageshack.us/img827/5904/20120125102247.png a busy cat http://img444.imageshack.us/img444/3855/20120125102202.png namespace serialport { public class Program {

Converting stateful React component to stateless functional component: How to implement “componentDidMount” kind of functionality?

让人想犯罪 __ 提交于 2019-12-10 04:37:03
问题 I have written a small stateful React component. When this component loads, in componentDidMount method I am making use of Kendo UI to show the content of the component in a popup window. Here's my code: export class ErrorDialog extends React.Component { constructor(props, context) { super(props, context); this.errorPopupWindow = null; window.addEventListener('resize', this.resizeComponent); this.handleWindowKeyDown = this.handleWindowKeyDown.bind(this); this.handleButtonCloseWindowOnClick =

VoiceOver accessibility in a virtual musical instrument iPhone app?

不羁岁月 提交于 2019-12-10 03:12:23
问题 I have received comments from blind users that some of my sound and music related apps only work with VoiceOver off. With VoiceOver Accessibility enabled on an iOS device, is it possible to enable a music keyboard or drum pad touch area so that music sounds can be played immediately, instead of VoiceOver prompts, when a keyboard key or virtual drum set (etc.) is tapped? Just setting the UIAccessibilityTraitPlaysSound AccessibilityTrait on a UIView subview doesn't seem to do it. I get

Prevent disabled UIButton from propagating touch events

我是研究僧i 提交于 2019-12-10 01:23:48
问题 My application has two overlapping UIButtons. The top button may be disabled at times. However, in this case any touch events it receives seem to be passed down to the underlying view, which in my case is the other button. What I need is the top button intercepting all touches and preventing them from reaching the bottom button, even in disabled state (I would be happy even if it's designated action is invoked in the disabled state). So far I've tried: [topButton setUserInteractionEnabled:YES

Can I determine if a KeyEventArg is an letter or number?

一世执手 提交于 2019-12-10 01:21:17
问题 Is there a way to determine if a key is letter/number ( A-Z , 0-9 ) in the KeyEventArgs ? Or do I have to make it myself? I found a way with e.KeyCode, is that accurate? if(((e.KeyCode >= Keys.A && e.KeyCode <= Keys.Z ) || (e.KeyCode >= Keys.D0 && e.KeyCode <= Keys.D9 ) || (e.KeyCode >= Keys.NumPad0 && e.KeyCode <= Keys.NumPad9)) 回答1: You can use the char.IsLetterOrDigit() method on the KeyCode of the event args: bool isLetterOrDigit = char.IsLetterOrDigit((char) keyEventArgs.KeyCode); 回答2:

Javascript click and mousedown conflicting

蓝咒 提交于 2019-12-10 00:50:31
问题 I have a certain scenario where I'm using click to insert a div and then mousedown on that div for dragging it around. I have bound the click to the parent container, and the mousedown on the div itself. But when I mousedown on the div, it fires the click on the parent as well, hence inserting multiple divs instead of dragging the already added div! Is there a way to solve this issue? I can't unbind click , since I need to add 2 divs using the click , and then bind mousedown on these. Update:

C#: Initializing an event handler with a dummy

走远了吗. 提交于 2019-12-09 18:22:01
问题 I've seen this sort of code some places: public event SomeEventHandler SomeEvent = (s, e) => { }; Is that a recommended way of doing things? What does it solve, and does it have any noteworthy side effects? Will I still have to do null checks? Or is that exactly what I don't have to do any more? Will garbage collection still work as it should? For example: private PropertyChangedEventHandler propertyChanged; private readonly object propertyChangedLock = new object(); public event