event-handling

Overwritten “this” variable problem or how to call a member function?

廉价感情. 提交于 2019-11-29 17:05:33
I have this class where I am using a combination of jQuery and Prototype : var MyClass = Class.create({ initElements: function(sumEl) { this.sumEl = sumEl; sumEl.keyup(this.updateSumHandler); }, updateSumHandler: function(event) { // Throws error here: "this.updateSum is not a function" this.updateSum(); }, updateSum: function() { // does something here } }); How can I call this.updateSum() after all? You need to use closures. initElements: function(sumEl) { this.sumEl = sumEl; var ref = this; sumEl.keyup( function(){ref.updateSumHandler();}); }, Martijn Laarman Totally untested suggestion:

How to create an event handler for multiple buttons?

社会主义新天地 提交于 2019-11-29 16:34:26
In my C# project, I am creating a Hangman game that has a set of buttons which contains the alphabets from A to Z. All these buttons when clicked will execute the same method. I do not want to create an event handler for each of them one by one. So how do I create a SINGLE event handler for all these buttons? Subscribe same handler for all buttons and use sender to get button which raised event: void Button_Click(object sender, EventArgs e) { Button button = (Button)sender; // use Name or Tag of button } If your buttons named as alphabets A .. Z then you can just use button.Name to get letter.

Find all event handlers for a Windows Forms control in .NET

别说谁变了你拦得住时间么 提交于 2019-11-29 16:08:27
Is there a way to find all event handlers for a Windows Forms control? Specifically statically defined event handlers? Hans Passant Windows Forms has strong counter-measures against doing this. Most controls store the event handler reference in a list that requires a secret 'cookie'. The cookie value is dynamically created, you cannot guess it up front. Reflection is a backdoor, you have to know the cookie variable name. The one for the Control.Click event is named "EventClick" for example, you can see this in the Reference Source or with Reflector. This is all incredibly unpractical, if you

Adding event listener to audio HTML5 tag in javascript

巧了我就是萌 提交于 2019-11-29 16:07:01
问题 Hi I'm creating a new audio tag element in Javascript this is the code: var audio = document.createElement("audio"); audio.setAttribute("id","myid"); audio.setAttribute("autoplay","autoplay"); document.body.appendChild(audio); before appending it to the body, I'd like to place an onended event handler, I tried something like this: audio.onended = foo; where foo is something like: function foo(){alert('Hola')} and audio.setAttribute("onended","foo()"); in both case it didn't work. In the first

Listen for Events from Browser “Find” Window in JavaScript

北城余情 提交于 2019-11-29 15:39:46
Is there a way to listen for typing into the browser's "find" window in JavaScript? I'd like to be able to reinterpret the search text from JavaScript. What do I need to add an event listener for? I don't know of any way you can listen for a find -like event and if that's supported in any browser it sure isn't a portable solution. I also don't know what you're trying to achieve but I think that your best option is to listen for the keyboard events that trigger the find window and attempt to cancel them while attempting to emulate the find-toolbar/window with JavaScript of your own. This is

C# Events: How to process event in a parallel manner

限于喜欢 提交于 2019-11-29 15:22:15
问题 I have an event which I would like to have processed in a parallel manner. My idea is to make each callback be added to the ThreadPool, effectivley having each method that registered the event handled by the ThreadPool. My try-out code looks something like the following: Delegate[] delegates = myEvent.GetInvocationList(); IAsyncResult[] results = new IAsyncResult[ delegates.Count<Delegate>() ]; for ( int i = 0; i < delegates.Count<Delegate>(); i++ ) { IAsyncResult result = ( ( TestDelegate

C++ MSAPI 5: SetNotifyCallbackFunction not working

此生再无相见时 提交于 2019-11-29 14:39:53
So I've tried the MSAPI 5.4 TTS with event example . Now I create an cmd prompt app that utilize the SetNotifyCallbackFunction but the function that I've pass is not being called. I'm not an expert in C++ so I am having difficulty in solving this one, can anyone point me in the right direction or at least give me a good example of SetNotifyCallbackFunction? Here is a simplified version of my code: typedef void __stdcall SPNOTIFYCALLBACK(WPARAM wParam, LPARAM lParam); void __stdcall outsideeventFunction(WPARAM, LPARAM); void __stdcall outsideeventFunction(WPARAM wParam, LPARAM lParam){ std:

JavaFX 2 event dispatching to underlying nodes

雨燕双飞 提交于 2019-11-29 14:20:13
Is there a correct way to solve the problem with event propagation between two sibling panes? For example we have StackPane with 2 panes inside. StackPane p = new StackPane(); Region p1 = new Region(); Region p2 = new Region(); p.getChildren().addAll(p1, p2); p2 in this example capture mouse events and p1 can't react on it even if event is not consumed. Is there a correct way to propagate event to p1 if it not consumed by p2? setMouseTransparent not solve my problem because I need that both children elements react on mouse. Thanks for advise. By default events will just propagate up the

How can I get an actual EventHandler delegate instance from an event in VB.NET?

旧街凉风 提交于 2019-11-29 14:12:38
In C#, I could do something like this: EventHandler handler = this.SomeEvent; ...which would allow me to, for example, do: Delegate[] attachedHandlers = handler.GetInvocationList(); In VB.NET, I can't seem to figure out how to do a similar thing. This doesn't work: Dim handler As EventHandler = Me.SomeEvent ...due to the following error: Public Event SomeEvent(sender As Object, e As EventArgs)' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event. But this doesn't work either: Dim handler As EventHandler = AddressOf Me.SomeEvent ...because: 'AddressOf'

touch events firing twice

泪湿孤枕 提交于 2019-11-29 14:08:25
问题 I am having problems on mobile devices/tablets with the events firing twice. When I click the following function, the menu that is supposed to drop down will drop down then immediataly slide back up. It is only an issue with touch devices. $(document).on("touchend click", ".lines-button", function(e){ e.stopImmediatePropagation(); if($(this).hasClass("close")){ $(this).removeClass("close"); $(".widget1x1Back").next(".actionsHolder3").slideUp("fast", function() { $(this).remove(); }); }else{