event-handling

C# How to find if an event is hooked up

有些话、适合烂在心里 提交于 2019-11-26 17:19:51
I want to be able to find out if an event is hooked up or not. I've looked around, but I've only found solutions that involved modifying the internals of the object that contains the event. I don't want to do this. Here is some test code that I thought would work: // Create a new event handler that takes in the function I want to execute when the event fires EventHandler myEventHandler = new EventHandler(myObject_SomeEvent); // Get "p1" number events that got hooked up to myEventHandler int p1 = myEventHandler.GetInvocationList().Length; // Now actually hook an event up myObject.SomeEvent += m

Adding multiple onload handlers

若如初见. 提交于 2019-11-26 17:18:17
问题 I have two js files, each one with its own window.onload handler. Depending on how I attach the two onload handlers to the window object I get a different behaviour on the second handler. More specifically, here is my html file: <html> <head> <title>Welcome to our site</title> <script type="text/javascript" src="script1.js"> </script> <script type="text/javascript" src="script2.js"> </script> </head> <body id="pageBody"> <h2 align="center"> <a href="http://www.whatever.com" id="redirect">

D3: How do I set “click” event and “dbclick” event at the same time?

六眼飞鱼酱① 提交于 2019-11-26 17:13:19
问题 I've toggled click event to a node and I want to toggle a dbclick event to it as well. However it only triggers the click event when I dbclick on it. So How do I set both events at the same time? 回答1: You have to do your "own" doubleclick detection Something like that could work: var clickedOnce = false; var timer; $("#test").bind("click", function(){ if (clickedOnce) { run_on_double_click(); } else { timer = setTimeout(function() { run_on_simple_click(parameter); }, 150); clickedOnce = true;

C# Console App + Event Handling

孤者浪人 提交于 2019-11-26 17:09:36
问题 Hey all. I'm trying to see about handling events in a console application. I would prefer to not use silent WinForms (though I understand that that's one way) to do it. I've read over a similar question and its response. See response text below (link): The basic requirement of an STA thread is that it needs to run a message pump. In Windows Forms, you can use Application.Run. Or you could write the message pump by hand, using user32!GetMessage & DispatchMessage. But it's probably easier to

How can I post-process the data from an Excel web query when the query is complete?

北城以北 提交于 2019-11-26 17:08:58
问题 As a spreadsheet developer, I am trying to stitch together two sets of rows: one from a web query to a web service I own, and the other a set of manual rows added by the spreadsheet's user (not me). Excel's built in Web Query / Connections object only provides two modes: I can turn on "Enable background refresh" which makes the web query asynchronous, or uncheck it. With it unchecked, Excel freezes up while the query executes, which is undesireable. With it checked, there doesn't seem to be

is event a global variable that is accessible everywhere inside the callback chain?

陌路散爱 提交于 2019-11-26 17:00:00
问题 I was just playing around with event listeners with DOM and javascript and did notice this: function chained(msg) { console.log(msg, event); } function onClick() { chained('the body was clicked'); } document.body.addEventListener('click', onClick); Now the funny thing...this will output: "the body was clicked, (MouseEvent)" Then I ask, why? how does it passes the event object without sending it on the chained call? function chained(msg) { console.log(msg, namedEventObj); //throw error

Add an event handler to jqGrid after instantiation

荒凉一梦 提交于 2019-11-26 16:44:11
问题 I want to add an event handler to jqGrid (for the onSelectRow event) but after the grid has already been created on the page i.e. I cant hardcode it into the initial jqGrid definition. I have tried using setGridParam to set an event handler for onSelectRow but that didnt work :( $('#list').jqGrid('setGridParam', { onSelectRow: function(id){ alert(id); } } ); The jqGrid docs are quite difficult to get what you want out of them and I havent found anything regarding this problem. 回答1: I just

How to register multiple external listeners to the same selection in d3?

不问归期 提交于 2019-11-26 16:35:45
问题 I'm writing a project in d3 in which I have an html page incorporating two external javascript files, say script_1.js and script_2.js . I need to register one event listener from script_1.js and another from script_2.js for the change event on a select element. At present I have this line in my html: <select id="timebasis" class="selector" onchange="selectIndexSp(this),selectIndexBt(this)"> where selectIndexSp(object) and selectIndexBt(object) are defined respectively in script_1.js and

capture click on div surrounding an iframe

偶尔善良 提交于 2019-11-26 16:34:51
How can i capture a click or mousedown event on a div surrounding an iframe. I've tried attaching the funciton to click event on the div but since the iframe never bubbles the event up to the surrounding div the function is never called. Is there a way i can capture the event on the div and then propagate it to the iframe for default action If the click is in the iframe area, the iframe context handles the click event, it does not bubble up to the iframe parent. So the div will never register the click event at all if it happened in the iframe area. Furthermore, if the iframe contains a page

How can I subscribe multiple buttons to the same event handler and act according to what button was clicked?

半世苍凉 提交于 2019-11-26 16:34:25
I have 6 buttons that I want to be attached to the same handler. How can I do this? When you subscribe to the event on a button, it's just a standard event handler: button1.Click += myEventHandler; You can use the same code to add handlers for every button: button1.Click += myEventHandler; button2.Click += myEventHandler; button3.Click += myEventHandler; button4.Click += myEventHandler; button5.Click += myEventHandler; button6.Click += myEventHandler; This will cause your handler in myEventHandler to be run when any of the buttons are clicked. You can attach the same event to multiple buttons