event-handling

jQuery: Is it illegal or bad practice to assign multiple event handlers? [duplicate]

China☆狼群 提交于 2019-12-04 18:01:49
Possible Duplicate: jQuery: more than one handler for same event I am using a jQuery slider plugin that creates two buttons. These buttons have click events attached to them by the plugin as they are used to control the slider. I have created my own mouseover\mouseout events independent of the plugin (inline with the webpage) to handle animations. I would like to create one for click as well (so that the button changes color). Will me creating another click event handler override or break what the plugin does? Is it bad practice and is there a better way? Having two events is no problem. You

Cast Boxed Object back to Original Type

限于喜欢 提交于 2019-12-04 17:46:00
问题 I expect there's one of two answers to this, either impossible or extremely simple and I've overlooked the obvious Google query. The underlying issue is that I have a generic object being passed in via an EventHandler that boxes the object and obfuscates the true type; only at runtime do I know what the object is. Admittedly the dynamic keyword can get around the issue, but I'd like to not lose IntelliSense and everything if I can avoid it. Plus, it doesn't solve not knowing what each of the

LongClick event also triggers Click event

余生颓废 提交于 2019-12-04 16:39:43
问题 I use onLongClick and onClick events of a button to get user inputs. Whenever; the user long click and triggers onLongClick event, the onClick event is also triggered. I couldn't find my problem. The code of two methods are shown in below: @Override public void onClick(View v) { switch(((Button) v).getId()) { case R.id.enter: EntertheNumber(); break; case R.id.clear: CleartheNumber(); break; case R.id.number_zero: case R.id.number_one: case R.id.number_two: case R.id.number_three: case R.id

Creating Buttons Dynamically, Could I select one and deselect the other buttons?

别说谁变了你拦得住时间么 提交于 2019-12-04 16:31:47
I'm creating buttons dynamically ... for(int i=0; i<colSize;i++){ final Button btn = new Button(this); btn.setText(SectionName[i]); btn.setTextSize(10); btn.setPadding(8, 3,8, 3); btn.setTextColor(Color.WHITE); btn.setTypeface(Typeface.SERIF, Typeface.BOLD); btn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { //***Every time that I click my button is selected !:) btn.setSelected(true); } }); } But how could I deselect the other buttons that were selected, I just want one Button selected! :) Declare a variable to store the Id of the Clicked Button :: private

Javascript, click, doubleclick and drag in the same element

偶尔善良 提交于 2019-12-04 16:25:19
I'm in need of a function that figures out if the user is clicking, double-clicking or dragging the mouse. Since it's all happening in the same canvas using the normal events doesn't work. I found this through google: It is inadvisable to bind handlers to both the click and dblclick events for the same element. The sequence of events triggered varies from browser to browser, with some receiving two click events and others only one. If an interface that reacts differently to single- and double-clicks cannot be avoided, then the dblclick event should be simulated within the click handler. We can

Add event for PictureBox mouse down

我与影子孤独终老i 提交于 2019-12-04 15:50:02
I want to make this event to work: private void pictureBox1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { //code } I know I have to add an event for this to work but I wasn't able to find the syntax anywhere. How can I add this event? You have to assign event handler to the event, usually in the form's constructor: class MyForm { PictureBox pictureBox1; public MyForm() { ... InitializeComponent(); ... pictureBox1.MouseDown += new MouseEventHandler(pictureBox1_MouseDown); ... } } If you added your control through Form Designer in Visual Studio, it will automatically generate

Block code and wait for event handler to fire?

夙愿已清 提交于 2019-12-04 15:30:48
I'm writing an application that uses a 3rd party library to process some data. In a very simplified example, I have a method which runs as a task like this: private void ProcessListOfItems(List<string> items) { while (items.Count > 0) { 3rdPartyLibObject.Process(items[0]); items.Remove(0); } } As you can see, the way my code is currently written, I remove each item from the list as soon as the Process() method returns. But it's possible that the processing of an item could fail and I need to know if that happens. Unfortunately, the Process() method does not return a bool value to indicate that

C# Is it thread safe to subscribe Same event handler for all Objects

倾然丶 夕夏残阳落幕 提交于 2019-12-04 15:13:44
I have a situation in my project where i have connect to multiple server and listen for events. Whenever a event received from the server, Handler should add the event to the common queue for processing. All connections should add received events to the queue. foreach(var item in collection) { Connection c = new connection(item); c.start(); c.EventReceived+=new EventHandler(myHandler); list.add(c); } protected void myHandler(eventArgs) { //add it to the concurrent queue } Here i doubt that whether it can be able to handle those events without any threading issues. Please let me know if you

Remove only one specific event handler in vb.net

南楼画角 提交于 2019-12-04 14:49:02
I'm writing a small 2D engine that uses Lua to control it. I've been setting events up in between the Lua and the VB.net for the past little while here. The problem, I've realized, is that is that I can't seem to remove the events which is screwing up quite a few things (because they are being called when they should be done with). To fix this, I wanted to add some kind of way to remove the specific event handler. I know how to add an event handler: AddHandler Button1.Click, AddressOf Button1Clicked But with this in mind, is their a way to remove a specific event handler in the VB.net? Thanks!

jqueryMobile tap and bubbling/propagation

ぐ巨炮叔叔 提交于 2019-12-04 13:54:55
See this sample in android 2.x browser..its a sample to replicate a scenario in my application.. http://johnchacko.net/samples/tap.html Its about listening to 'tap' and calling changePage from listener... The second page is having some input fields, 'tap' event is bubbling/propagating to second page and focus is randomly set to input fields... I read similar issues and want to know anybody experienced same issue and got a workaround for it.... Or I must use only 'click' ? It can be fixed in few ways: On tap/click event use this methods before you call changePage: e.stopPropagation(); e