event-handling

Advantage of Functional Reactive Programming over event-listeners

雨燕双飞 提交于 2019-11-28 03:37:16
问题 I've been hearing a lot about functional reactive programming, and decided to check out what the big deal is. Going through the bacon.js documentation, it seems that the main difference is that instead of setting an event listener on a component, I create an event stream on it, and pass the event handler into the stream instead. In other words, all I really did was move the event handler from the component to the event stream. Is that it? If so, what's the big advantage of doing this? 回答1: Is

onTouch, onLongClick together in android

徘徊边缘 提交于 2019-11-28 03:35:38
问题 I'am adding imageviews to parent layout dynamically. And i'am performing zoom in/out operations onTouch of added image. I want to remove the added view onLongPress of it. img.setOnLongClickListener(longClickAction); img.setOnTouchListener(touchAction); onLongPress : OnLongClickListener longClickAction = new OnLongClickListener() { @Override public boolean onLongClick(View v) { parentLayout.removeView((ImageView)v); return false; } }; onTouch : OnTouchListener touchAction = new OnTouchListener

jQuery live('click') firing for right-click

跟風遠走 提交于 2019-11-28 03:16:38
问题 I've noticed a strange behaviour of the live() function in jQuery: <a href="#" id="normal">normal</a> <a href="#" id="live">live</a> $('#normal').click(clickHandler); $('#live').live('click', clickHandler); function clickHandler() { alert("Clicked"); return false; } That's fine and dandy until you right-click on the "live" link and it fires the handler, and then doesn't show the context menu. The event handler doesn't fire at all (as expected) on the "normal" link. I've been able to work

Unable to get Scene from MenuItem in JavaFX

北战南征 提交于 2019-11-28 03:15:51
问题 I am trying to change the scene in a javafx stage based on menuItem click. Here is my sample.fxml: <?xml version="1.0" encoding="UTF-8"?> <?import java.lang.*?> <?import java.net.*?> <?import javafx.geometry.Insets?> <?import javafx.scene.control.*?> <?import javafx.scene.control.Button?> <?import javafx.scene.control.Label?> <?import javafx.scene.image.*?> <?import javafx.scene.layout.*?> <?import javafx.scene.layout.GridPane?> <AnchorPane prefHeight="-1.0" prefWidth="560.0" styleClass=

Question regarding to value/reference type of events

ⅰ亾dé卋堺 提交于 2019-11-28 03:01:37
问题 On the MSDN, I have found following: public event EventHandler<MyEventArgs> SampleEvent; public void DemoEvent(string val) { // Copy to a temporary variable to be thread-safe. EventHandler<MyEventArgs> temp = SampleEvent; Is it reference? If so I do not understand its meaning as when SampleEvent became null, so does the temp if (temp != null) temp(this, new MyEventArgs(val)); } 回答1: This is a paranoia thing to do with threading. If another thread unsubscribes the last handler just after you

How to call function on child component on parent events

孤人 提交于 2019-11-28 02:51:23
Context In Vue 2.0 the documentation and others clearly indicate that communication from parent to child happens via props. Question How does a parent tell its child an event has happened via props? Should I just watch a prop called event? That doesn't feel right, nor do alternatives ( $emit / $on is for child to parent, and a hub model is for distant elements). Example I have a parent container and it needs to tell its child container that it's okay to engage certain actions on an API. I need to be able to trigger functions. Give the child component a ref and use $refs to call a method on the

JavaFX - Difference between EventDispatcher and EventFilter

不想你离开。 提交于 2019-11-28 02:26:41
问题 I am trying to understand when to use EventDispatcher in JavaFX. I am pretty much aware of all the event mechanisms of capturing and bubbling. But I am still confused with the purpose of EventDispatcher. Because I can get most of my work done using filters & handlers. Can someone please explain what is the actual purpose and how to use this EventDispatcher? Thank You. 回答1: Purpose of EventDispatcher As the name suggests, the purpose of an EventDispatcher is to dispatch an Event . The way it

javascript click event handler fires without clicking

拈花ヽ惹草 提交于 2019-11-28 02:17:04
Why does this function get fired without having clicked on the specified button? I had a look at a few similar problems but none deal with this code structure (might be obvious reason for this im missing...). document.getElementById("main_btn").addEventListener("click", hideId("main"); function hideId(data) { document.getElementById(data).style.display = "none"; console.log("hidden element #"+data); } Suresh Atta You are directly calling it. document.getElementById("main_btn").addEventListener("click", hideId("main"); You should do that in a callback. document.getElementById("main_btn")

re-firing a click event on a link with jQuery

自闭症网瘾萝莉.ら 提交于 2019-11-28 02:13:27
i've got a page (asp.net) where I trap the click event of a link. i then do some dirty checking and present a dialog to the user, $(function() { var clickedLink; $('.checkdirty').click(function(event) { if(isDirty == false){ return true; } clickedLink = $(this); $('#dirtysave-dialog').dialog('open'); return false; }); }); do you want to loose your changes Yes/No etc. $('#dirtysave-dialog').dialog({ bgiframe: true, autoOpen: false, height: 125, width: 425, modal: true, title: "You have unsaved changes, do you want to continue and loose changes?!!", buttons: { "Yes": function() { isDirty = false

Messaging system: Callbacks can be anything

萝らか妹 提交于 2019-11-28 01:55:29
问题 I'm trying to write an event system for my game. The callbacks that my event manager will store can be both plain functions as well as functors. I also need to be able to compare functions/functors so I know which one I need to disconnect from the event manager. • Initially I tried using boost::function; it handles functions and functors perfectly well, except it has no operator==, so I can't remove callbacks if I want to. class EventManager { typedef boost::function<void (boost::weak_ptr