event-handling

In C# why can't I pass another class' EventHandler reference and how can I get around it?

自闭症网瘾萝莉.ら 提交于 2019-11-30 09:02:43
If I have ClassA that has a public event, SomeEvent, and ClassC that has method, addListener, that accepts an EventHandler reference, why can't ClassB have a line that says c.addListener(ref a.SomeEvent)? If I try I get a compiler error that says: "The event 'ClassA.SomeEvent' can only appear on the left hand side of += or -= (except when used from within the type 'ClassA'). Why does this restriction exist? And how can I get around it while staying reasonably close to my structure? I'm a C# newbie; any help would be appreciated. Thanks! class ClassA { public event EventHandler SomeEvent; }

How to use delegates in correct way / Understanding delegates

时光总嘲笑我的痴心妄想 提交于 2019-11-30 08:37:28
问题 use - C# (.Net Framework 4.5, Visual Studio 2012) I try to understand such theme like Delegate, and currently I have few points, that must be clarified for me. I found a lot of different information in internet that describe how to use it, but it's a little bit complicated to understanding for me this theme. As I understand I must to do few thing for using delegate: Create some entity for work with it (that require creating some delegate) Declare a delegate type Create some method where I

Triggering an event handler on an element inside iframe from parent frame

让人想犯罪 __ 提交于 2019-11-30 08:22:40
问题 I have a html page. Inside it I use jQuery to attach click event on a link. Then I use iframe to reference this html page from another page. However I could not trigger the event attached on that link with js (when I click the link with the mouse, the event gets triggered with no problem). How can I trigger that event from parent frame? I have tried the following but it does not work: var frame = $('#mainFrame'); // the iframe I am trying to access var link = $('a.btn', frame.contents()); //

Listening to events such as adding new elements in JavaScript

*爱你&永不变心* 提交于 2019-11-30 08:15:46
I need to create an event listener such that, when a new element is added to the document, or any of its child, my event handler gets called. Any ideas how to do this using? .bind('DOMNodeInserted DOMNodeRemoved') this are the events to check element is inserted or removed. bind on parent element this event. and call your function in handler js fiddle demo : http://jsfiddle.net/PgAJT/ click here for example ... http://help.dottoro.com/ljmcxjla.php Mutation events are deprecated, use Mutation Observer instead. You can also use arrive.js library, it uses Mutation Observer internally and provides

VBA trigger macro on cell value change

╄→尐↘猪︶ㄣ 提交于 2019-11-30 07:36:19
问题 This should be simple. When the value of a cell changes I want to trigger some VBA code. The cell (D3) is a calculation from two other cells =B3*C3 . I have attempted 2 approaches: Private Sub Worksheet_Change(ByVal Target As Range) If Target.Column = 4 And Target.Row = 3 Then MsgBox "There was a change in cell D3" End If End Sub Since the cell is a calculation this is not triggered when the value changes, because the calculation remains the same. I also tried: Private Sub Worksheet_Calculate

Can i access outer class objects in inner class [duplicate]

妖精的绣舞 提交于 2019-11-30 07:21:57
问题 This question already has answers here : What's the best way of accessing field in the enclosing class from the nested class? (8 answers) Closed 6 years ago . I have three classes like this. class A { public class innerB { //Do something } public class innerC { //trying to access objB here directly or indirectly over here. //I dont have to create an object of innerB, but to access the object created by A //i.e. innerB objInnerB = objB; //not like this innerB objInnerB= new innerB(); } private

How do I attach an event handler to a panel in extJS?

时光毁灭记忆、已成空白 提交于 2019-11-30 07:14:32
问题 All I want to do is handle a click on an extJS panel . I've tried all the of suggestions on this question plus all I could find elsewhere but each of them fail in the ways described below. What is the correct syntax to add a click event handler to a extJS panel? [ Edit : For the sake of others who may find this question later, I'll add some comments inline to make this easier to decipher --@bmoeskau] doesn't execute handler: var menuItem1 = new Ext.Panel({ id: 'panelStart', title: 'Start',

JTable: Detect cell data change

谁说胖子不能爱 提交于 2019-11-30 07:04:18
问题 In Netbeans, I used the GUI Builder to insert a JTable into my application. I have just one class (CustomerDB) so far which is: package CustomerDB; import [...]; public class CustomerDB extends javax.swing.JFrame { CellEditorListener ChangeNotification = new CellEditorListener() { public void editingCanceled(ChangeEvent e) { System.out.println("The user canceled editing."); } public void editingStopped(ChangeEvent e) { System.out.println("The user stopped editing successfully."); } }; public

Creating Observable from normal Java events

给你一囗甜甜゛ 提交于 2019-11-30 06:39:32
What is the best way to create an Rx-Java Observable from the classical Java event pattern? That is, given class FooEvent { ... } interface FooListener { void fooHappened(FooEvent arg); } class Bar { public void addFooListener(FooListener l); public void removeFooListener(FooListener l); } I want to implement Observable<FooEvent> fooEvents(Bar bar); The implementation I came up with is: Observable<FooEvent> fooEvents(Bar bar) { return Observable.create(new OnSubscribeFunc<FooEvent>() { public Subscription onSubscribe(Observer<? super FooEvent> obs) { FooListener l = new FooListener() { public

jQuery detect mousedown inside an element and then mouseup outside the element

浪尽此生 提交于 2019-11-30 06:36:37
I have something similar to a drawing canvas, and I capture it's state on mouseup for undo purposes. The canvas isn't full screen, so you can draw with a brush and release outside the canvas. Something like this: $("#element").mousedown(function(){ $(document).mouseup(function(){ //do something }); }); But this doesn't work of course. A plain $(document).mouseup doesn't work either, because I have many other UI elements and it saves the state each time you click on a UI element. Any ideas? var isDown = false; $("#element").mousedown(function(){ isDown = true; }); $(document).mouseup(function()