event-handling

Using VCL TTimer in Delphi console application

匆匆过客 提交于 2019-12-03 09:22:59
问题 As the question subject says. I have a console application in Delphi, which contains a TTimer variable. The thing I want to do is assign an event handler to TTimer.OnTimer event. I am totally new to Delphi, I used to use C# and adding the event handlers to events is totally different. I have found out that one does not simply assign a procedure to event as a handler, you have to create a dummy class with a method which will be the handler, and then assign this method to the event. Here is the

Telling Firebug to Break as Soon as any Javascript is Executed

人盡茶涼 提交于 2019-12-03 09:19:50
问题 I've inherited a pile of code that's doing unexpected things when I click on some <button> elements. The page has a lot of Javascript, and it's unclear what, if any, events have been setup on the button or its parent elements. I'm trying to find where execution starts so I can debug what's going on. Is there a way to have Firebug (or any Javascript debugger) break whenever any javascript code is executed? Maybe someway to setup a break point on each line programmatically? Or is there some

javascript: how adding event handler inside a class with a class-method as the callback?

大兔子大兔子 提交于 2019-12-03 07:53:30
How do i add an event handler inside a class with a class-method as the callback ??? <div id="test">move over here</div> <script> oClass = new CClass(); function CClass() { this.m_s = "hello :-/"; this.OnEvent = OnEvent; with(this) { var r = document.getElementById("test"); r.addEventListener('mouseover', this.OnEvent); // this does NOT work :-/ } function OnEvent() { alert(this); // this will be the HTML div-element alert(this.m_s); // will be undefined :-() } } </script> Yes i know some quirks to make it work but what would be the intended way when these event handlers were introduced ??? I

How to make a click or double click on a word on a web page to trigger an event handler?

佐手、 提交于 2019-12-03 07:32:18
问题 For a page like http://www.answers.com if the user double clicks on any word in the page, a pop up box will show up and shows the definition for that word. I can think of a way to use DOM scripting to break up all words in the page and then make each of them go under a separate "span" element... but otherwise isn't it true that if all the text is under a "p" element, then the "p" element node get triggered to handle the double click event, but there is no easy way of telling which word is

How to remove all event listeners from a display object?

萝らか妹 提交于 2019-12-03 07:19:51
Is there a way to determine which event listeners are registered with a display object? I want to remove all event listeners from a display object so that I can assign new ones based on context changes in the application. jeceuyper is right ... a side not though: DisplayObject extends EventDispatcher , which already does implement IEventDispatcher ... so to be more precise: you need to override addEventListener and removeEventListener to keep track of the listeners ... a few technical details: i suggest you use Dictionary to store the handler functions ... a bit slower for insertion, but much

How to disable JQuery keypress event for just one element?

喜欢而已 提交于 2019-12-03 07:19:01
问题 On my site I have registered a keypress event handler for the whole document. $(document).keypress(myhandler); And I handle the 'space' key to scroll a list. Trouble is, there is an <input type='text' /> element, and I don't want 'space' keypress to scroll the list when it is entered in the input. I couldn't find any information in the "event" object passed by JQuery to the handler, to identify where the source of the event is. 回答1: Alternatively, you could attach another event handler to the

UIActivityViewControllerCompletionHandler How to?

若如初见. 提交于 2019-12-03 06:45:57
问题 I am trying to use the UIActivityViewControllerCompletionHandler , but i dont quite get how.. I want to detect when the user finishes or dismisses this view controller ( UIActivityViewController ). Anyone knows how? 回答1: typedef void (^UIActivityViewControllerCompletionHandler) (NSString *activityType, BOOL completed); The second parameter of the completion handler tells you whether the user dismissed the controller. If they dismissed the controller, completed will be set to NO . There's more

Why *should* we use EventHandler

北战南征 提交于 2019-12-03 06:20:49
问题 I hate EventHandler. I hate that I have to cast the sender if I want to do anything with it. I hate that I have to make a new class inheriting from EventArgs to use EventHandler<T> . I've always been told that EventHandler is the tradition and blah, blah...whatever. But I can't find a reason why this dogma is still around. Is there a reason why it would be a bad idea to make a new delegate: delegate void EventHandler<TSender, T>(TSender sender, T args); That way the sender will be typesafe

Emulate W3C event capturing model in IE

爱⌒轻易说出口 提交于 2019-12-03 06:12:45
Is it possible to emulate event capturing in Internet Explorer? An example: <a>one</a> <a>two</a> <a>three3</a> <script> var links = document.getElementsByTagName("A"); for (var i=0; i < links.length; i++) { links[i].onclick = function(){ alert("clicked"); }; } </script> I want to prevent all these click events from firing. I can do that with a single event observer: document.addEventListener("click", function(e) { e.stopPropagation(); e.preventDefault(); }, true ); How can I do the same in IE? IE < 9 does not support addEventListener . It does support attachEvent , but it doesn't have

Which methods can be used to make thread wait for an event and then continue its execution?

风流意气都作罢 提交于 2019-12-03 05:54:38
问题 I have a thread running that delegates out some tasks. When a single task is complete, an event is raised saying that it has completed. These tasks need to be run in a specific order and need to wait for the previous task to finish. How can I make the thread wait until it receives the "task completed" event? (Aside from the obvious eventhandler that sets a flag and then a while loop polling the flag) 回答1: I often use the AutoResetEvent wait handle when I need to wait for an asynchronous task