event-handling

How to handle SelectedIndexChanged event for a ComboBox? [duplicate]

无人久伴 提交于 2019-11-29 10:55:42
This question already has an answer here: What event catches a change of value in a combobox in a DataGridViewCell? 4 answers I have DataGridView which contains two ComboBox columns. The second ComboBox will be filled with data depending on the selected value from first ComboBox . How to handle the SelectedIndexChanged event for the first ComboBox . A great resource for DataGridView questions can be found here: http://www.windowsclient.net/Samples/Go%20To%20Market/DataGridView/DataGridView%20FAQ.doc From there on how to handle a selected change event: How do I handle the SelectedIndexChanged

onTouch, onLongClick together in android

拈花ヽ惹草 提交于 2019-11-29 10:37:14
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() { @Override public boolean onTouch(View v, MotionEvent event) { ImageView i = (ImageView)v; /

Advantage of Functional Reactive Programming over event-listeners

心不动则不痛 提交于 2019-11-29 10:28:06
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? Bergi Is that it? No. It's about having event streams. You still will attach listener to them in the end to

Unable to get Scene from MenuItem in JavaFX

元气小坏坏 提交于 2019-11-29 09:59:09
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="background" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/2.2" fx:controller="sample

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

偶尔善良 提交于 2019-11-29 09:52:33
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 around it by changing the handler to this: function clickHandler(e) { if (e.button != 0) return true; //

Question regarding to value/reference type of events

百般思念 提交于 2019-11-29 09:32:10
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)); } This is a paranoia thing to do with threading. If another thread unsubscribes the last handler just after you've checked it for null , it could become null and you'll cause an exception. Since delegates are immutable,

Javascript sending key codes to a <textarea> element

浪尽此生 提交于 2019-11-29 08:46:44
I can't figure out how to trigger a keydown event on a textarea element, e.g. imagine i have two textarea elements and when i type something in the first one, I want the second box to show the typing as well, but for a certain reason I have to do it via events. This is what I tried and it doesn't work: <script language="javascript" type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js"></script> <textarea id='first'></textarea> <textarea id='second'></textarea> <script> jQuery("#first").keydown(function(event) { var keydown = jQuery.Event("keydown") keydown

Messaging system: Callbacks can be anything

ぃ、小莉子 提交于 2019-11-29 08:21:48
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<Event>)> Callback; std::map<Event::Type, std::vector<Callback>> eventHandlerMap_; }; • I also tried using

Change() inside each() jQuery

雨燕双飞 提交于 2019-11-29 08:16:38
What is the best way to manage this kind of situation : $('.element').each(function() { $sibling = // find a sibling to $this. $mainElement = $(this); // memorize $(this) $sibling.change(function() { // when sibling changes // do something using $mainElement // problem is, $mainElement is not the element you think // $mainElement is the last .element found.... }) }); One solution would be a table... But then there is no advantage for the change() to be nested in the each()... My html example : <div id="first"> <span class="element"></span> <input name="first" type="text" /> </div> <div id=

iOS - UIEventTypeRemoteControl events not received

≡放荡痞女 提交于 2019-11-29 07:46:20
I have this in the AppDelegate (didFinishLaunching): [[UIApplication sharedApplication] beginReceivingRemoteControlEvents]; I tried handling the events in the relevant view controllers but that was spotty (some view controllers would get the events and others wouldn't, even when they were first responders). I tried subclassing UIApplication. That didn't work. Now I'm trying to subclass UIWindow and do this (see the comments): - (void)sendEvent:(UIEvent *)event { if (event.type == UIEventTypeRemoteControl) { NSLog(@"I wish this happened"); //this never happens } else { NSLog(@"some other event"