event-handling

Garbage collection when using anonymous delegates for event handling

UPDATE I have combined various answers from here into a 'definitive' answer on a new question. Original question In my code I have an event publisher, which exists for the whole lifetime of the application (here reduced to bare essentials): public class Publisher { //ValueEventArgs<T> inherits from EventArgs public event Eve...

Elegant way to prevent circular events in MVC?

The question, in brief: In MVC, how do you distinguish between a checkbox click (or a selectbox or listbox change) from a human meaning "Controller, modify the model", and a checkbox click (or a selectbox or listbox change) from the Controller meaning "I'm updating the view because the model has changed"? The example: I have a JS ap...

JTable selection change event handling: find the source table dynamically

I've implemented my own event handler and added it to the selection model of the table: table.getSelectionModel().addListSelectionListener(event); And implemented the method for "event" (mentioned above): public void valueChanged(ListSelectionEvent e) { log.debug("value changed"); } Unfortunately the event fires twice if I chan...

Javascript: Event does not fire unless element appended to document.body

Hi All, I dynamically create an element (div) in javascript, on which i register an event listener: var tooltip = document.createElement('div'); tooltip.onclick = function() { alert('hello'); } Now, if I attach this element to the document body: document.body.appendChild(tooltip); all is well and the event is captured. However (fo...

install EventFilter on QWidget (qt4.4.3/kde4)

I have a K* window, and within it, a widget which needs the events filtered. For example I do not want the possibility of clicking it... How can I do that? Have I to use eventfilters? In this case, what's the best way? ...

Lambdas for event handlers?

Lambda syntax in C# 3 makes it really convenient to create one-liner anonymous methods. They're a definite improvement over the wordier anonymous delegate syntax that C# 2 gave us. The convenience of lambdas, however, brings with it a temptation to use them in places where we don't necessarily need the functional programming semantics ...

C#: DataGridView ComboBox Event Handling with a Dynamically Populated DataGridView

My Application creates a DataGrid based on XML. The XML is not optimized, but I have no control over that, so I have to "convert" it, and then add it, row by row, to the DataGrid. I have an event handler that must be fired when any of the DataGrid's ComboBoxes (all in one column) are changed. Problems: The event handling I have (in ...

Borland C++ Builder 5 - Cancel Via Escape Key Not Working

I'm having a rather perplexing problem with the Escape key handler on a dialog box in Borland C++ Builder 5. Are there any other requirements for the Escape key to fire a cancel event (other than those I've listed below)? The "Cancel" button (a TBitBtn) has its Cancel property set to true. The "Cancel" button has its Default property ...

Java: handling combined keyboard input

What is the correct way to separate between F1 and i.e. CTRL+F1 respective SHIFT-CTRL+F1 within an KeyListener registered behind i.e. a JButton? public void keyPressed(KeyEvent event) { int key = event.getKeyCode(); logger.debug("KeyBoard pressed char(" + event.getKeyChar() + ") code (" + key + ")"); } .. always gives me 112 ...

Javascript/Ajax - Manually remove event handler from a Sys.EventHandlerList()

I have two scriptcontrols, one holds the other, and I have successfully been able to handle events from the child on the parent using: initialize: function() { this._autoComplete = $get(this._autoCompleteID); this._onAutoCompleteSelected = Function .createDelegate(this, this.handleAutoCompleteSelected); var autoCont...

Testing that an event has an EventHandler assigned

Hi, I'm wanting to test that a class has an EventHandler assigned to an event. Basically I'm using my IoC Container to hook up EventHandlers for me, and I'm wanting to check they get assigned properly. So really, I'm testing my IoC config. [Test] public void create_person_event_handler_is_hooked_up_by_windsor() { IChangePersonSer...

Setting Up Event Handler in Delphi 2007 and Getting "Parameter Lists Differ" Error

I'm trying to write a class in Delphi 2007 that uses a ActiveX library. The class will catch an event that the ActiveX library has to expose its own event that adds some information to the ActiveX library's event. The bottom line is that when I assign my own procedure to the ActiveX library's event that I want to use, I get an error: ...

variable button vb.net

i declared a global variable button: Dim button1 As New Button() Now, i dont know how to add a click event in this button since it is a variable. Do you have any idea how do i do it? ...

Override Button_click event handler

I am developing a Win Forms application using a MVP pattern. I would like to pass the button clicked tag value to the presenter. Because I want to get the button.tag property I need to sender argument to be of type button. How can I do this with out doing this: private void button0_Click(object sender, EventArgs e) { ...

Receiving COM events

Without: ATL MFC Note: Plain C++ Out-of-process COM Object/server Predefined TLB file Question: How to implement an outgoing interface, so the COM Object can notify the sink of events? How to handle the event appropriately, once received? Below is the event function I'd like to implement - from TLB file: inline HRESULT IS8...

How to implement an outgoing interface on a sink object (C++)

I have a predefined TLB file, with IS8SimulationEvents wrapper method implementations, for instance: inline HRESULT IS8SimulationEvents::S8SimulationReset ( ) { HRESULT _result = 0; _com_dispatch_method(this, 0x1, DISPATCH_METHOD, VT_ERROR, (void*)&_result, NULL); return _result; } Using Oleview, I can see the IConnectionP...

Receiving keystrokes in an opened wx.ComboCtrl

Hi everyone! Coming from this question, I have a wxComboCtrl with a custom popup made of a panel with a bunch of radiobuttons.. My problem is that when I open the popup the combo doesn't get keystrokes, because the events get handled by the panel itself.. I'd like to redirect those KeyEvents to the textctrl of the combo, but I can't find...

dropdown list selectedchanged event is not firing

I am using Ajax enabled page and I did't use any control in this page. Even then SelectedIndexChanged event is not firing. I have added items from database, there is no repeatation and also set autopost back propety="true". I want to add items from database when select one item the selection always shows first element and selectedchanged...

How can I update a small field in a big SQL table if another field in the same row is changed by an external process?

I'd like to call Update ... Set ... Where ... to update a field as soon as that evil ERP process is changing the value of another. I'm running MS SQL. ...

Why do event handler methods randomly stop working?

Why would an event handler work one day, and then stop working the next day without any code changes? I have run into the problem many times, but always have to play around and somehow the event handler magically works again. Below is an example where this happened to me again today. Do you know a quick way to fix this type of problem...