event-handling

Multiple id's in a single JavaScript click event

…衆ロ難τιáo~ 提交于 2019-11-28 08:24:34
In JavaScript I am using click event to change chart data. Below is a method for click event. $('#pro1').click(function () { chart.series[0].update({ data: pro1 }); }); $('#pro2').click(function () { chart.series[0].update({ data: pro2 }); }); $('#pro3').click(function () { chart.series[0].update({ data: pro3 }); }); I need to minify these three click events in one event, means I want to write one click event which handle the id's. some thing like below code. $('#pro'+i).click(function () { chart.series[0].update({ data: pro+i }); }); I don't know how to do it exactly. The above code is not

Calling one method from another within same class in Python

时光毁灭记忆、已成空白 提交于 2019-11-28 07:33:28
I am very new to python. I was trying to pass value from one method to another within the class. I searched about the issue but i could not get proper solution. Because in my code, "if" is calling class's method "on_any_event" that in return should call my another method "dropbox_fn", which make use of the value from "on_any_event". Will it work, if the "dropbox_fn" method is outside the class? I will illustrate with code. class MyHandler(FileSystemEventHandler): def on_any_event(self, event): srcpath=event.src_path print (srcpath, 'has been ',event.event_type) print (datetime.datetime.now())

WithEvents/Handles better than Remove/AddHandler?

五迷三道 提交于 2019-11-28 07:31:16
问题 From a memory point of view (remove an added handler after utilization, etc.), is WithEvents and Handles usage preferable to RemoveHandler and AddHandler ? A related Stack Overflow question is Event handler and memory leaks . 回答1: It depends on what you're trying to achieve. If you have several event handlers which must handle events for various controls during the lifetime of a form/object then WithEvents and Handles is the easiest way to go. The language will do all of the dirty work for

Difference between Bubbling and Tunneling events

◇◆丶佛笑我妖孽 提交于 2019-11-28 07:29:22
What is the exact difference between Bubbling Events and Tunneling events? Where should I use Bubbling Events and where should I use Tunneling events? Thanks in Advance! Joetjah WPF gives us a number of different mechanisms for handling events – they are bubbling, tunneling, and direct. These are all known as Routed events. Direct event You are probably already used to the direct routed event. This is where the item itself handles the event that occurred. A good example would be handling he onClick -event of a mouse button in standard WinForms. This is where the event is raised in the GUI item

How to distinguish left click , right click mouse clicks in pygame?

╄→尐↘猪︶ㄣ 提交于 2019-11-28 07:20:30
问题 From api of pygame, it has: event type.MOUSEBUTTONDOWN, MOUSEBUTTONUP, MOUSEMOTION But there is no way to distinguish between right, left clicks? 回答1: if event.type == pygame.MOUSEBUTTONDOWN: print event.button event.button can equal several integer values: 1 - left click 2 - middle click 3 - right click 4 - scroll up 5 - scroll down Instead of an event, you can get the current button state as well: pygame.mouse.get_pressed() This returns a tuple: (leftclick, middleclick, rightclick) Each one

jQuery event handler .on() not working

痴心易碎 提交于 2019-11-28 07:12:59
I want to attach a event to dynamically created element class.So i used live function but it was not triggered. So checked live function reference ,there i red below notes As of jQuery 1.7, the .live() method is deprecated. Use .on() to attach event handlers. Users of older versions of jQuery should use .delegate() in preference to .live(). so decide to use on function,But it still not working.The text field is already attached with jquery ui datpicker.On another element select i disabled that field. jQuery("#from").attr('disabled','disabled') .removeClass('date_picker_bg') .removeClass(

How do I programmatically send ActionEvent to JButton?

别来无恙 提交于 2019-11-28 07:05:02
问题 How do I programmatically send an ActionEvent (eg button pressed/ACTION_PERFORMED) to a JButton ? I know of: button.doClick(0); and button.getModel().setArmed(true); button.getModel().setPressed(true); button.getModel().setPressed(false); button.getModel().setArmed(false); But isn't it possible to directly send it an ActionEvent ? EDIT: This is not production code, it's just a little personal experiment. 回答1: You can get a button's ActionListener s, and then call the actionPerformed method

How to detect ctrl-f in my SWT application

有些话、适合烂在心里 提交于 2019-11-28 07:01:58
I have written an SWT UI which has a primary function of displaying text in a StyledText control. I want to add a handler for Ctrl + F so that when that shortcut is pressed the focus is set to a search box. I have tried using the following code to detect the keypress. sWindow = new Shell(); ... sWindow.getDisplay().addFilter(SWT.KeyDown, new Listener() { @Override public void handleEvent(Event e) { System.out.println("Filter-ctrl: " + SWT.CTRL); System.out.println("Filter-mask: " + e.stateMask); System.out.println("Filter-char: " + e.character); } }); I was expecting that when I pressed Ctrl +

Can using lambdas as event handlers cause a memory leak?

扶醉桌前 提交于 2019-11-28 06:52:44
Say we have the following method: private MyObject foo = new MyObject(); // and later in the class public void PotentialMemoryLeaker(){ int firedCount = 0; foo.AnEvent += (o,e) => { firedCount++;Console.Write(firedCount);}; foo.MethodThatFiresAnEvent(); } If the class with this method is instantiated and the PotentialMemoryLeaker method is called multiple times, do we leak memory? Is there any way to unhook that lambda event handler after we're done calling MethodThatFiresAnEvent ? Yes, save it to a variable and unhook it. DelegateType evt = (o, e) => { firedCount++; Console.Write(firedCount);

Jquery / JS bind “paste” event handler to input textbox

删除回忆录丶 提交于 2019-11-28 06:32:14
Allright, SO i have an input box and I need to do things everytime it changes, I am having trouble doing it for mouse paste. Here is the code I have $("#attack-navy"+unit.ID+"-number").bind('paste', function(){ alert("paste detected"); $("#attack-max-capacity").text(getMaxCapacity()); }); the getMaxCapacity() function return number entered * 30 for now; Here is the scenario when 1: I paste 3, it will not change (i still see the alert) 2: Then when i paste 5, it will be 90(3 * 30) 3: Then if i paste 10 it will be 150(5 * 30), and so on. I think its doing the handler before the paste actually