event-handling

Why does OnMouseMove fire repeatedly when the mouse is not moving in D2010?

99封情书 提交于 2019-12-22 04:21:51
问题 I'm porting a Delphi 5 app to D2010, and I've got a bit of a problem. On one form is a TImage component with an OnMouseMove event that's supposed to update a label whenever the mouse is moved over the image. This worked just fine in the original app, but now the OnMouseMove event fires constantly whenever the mouse is over the image, whether it's moving or not, which causes the label to flicker horribly. Does anyone know what's causing this and how to fix it? 回答1: My psychic debugging sense

Event handling jQuery unclick() and unbind() events?

こ雲淡風輕ζ 提交于 2019-12-22 04:11:25
问题 I want to attach a click event to a button element and then later remove it, but I can't get unclick() or unbind() event(s) to work as expected. In the code below, the button is tan colour and the click event works. window.onload = init; function init() { $("#startButton").css('background-color', 'beige').click(process_click); $("#startButton").css('background-color', 'tan').unclick(); } How can I remove events from my elements? 回答1: There's no such thing as unclick() . Where did you get that

How to trigger custom event with jQuery?

倾然丶 夕夏残阳落幕 提交于 2019-12-22 04:04:24
问题 I'm attaching a custom event handler to the body in jQuery's ready method. Afterwards I immediately trigger the custom event but nothing seems to happen. $(function(){ $("body").on("test", function(){ alert("test triggered"); } $("body").trigger("test"); } 回答1: Firstly you have a syntax error $(function(){ $("body").on("test", function(){ alert("test triggered"); }); < ---- Missing this $("body").trigger("test"); }); Secondly you cannot trigger the event from the console , as $(function() {})

Why DragHandler exportAsDrag disables my MouseMotionListener?

痞子三分冷 提交于 2019-12-22 03:19:09
问题 I want to realize a simple JComponent-Drag-and-Drop with a preview from O.Reilly-Swing.Hacks Hack 69. Translucent Drag-and-Drop. My Problem is if the TransferHandler start the Drag the MouseMotionListener stop performing mouseDragged(). Here is a little Sample code: A small Window with a green and a red Side. The green Side do not start a Drag, always mouseDragged() is performed but the exportDone() will never reached. The red Side starts a Drag via exportAsDrag(), but after that the

event listeners vs. event handlers [duplicate]

随声附和 提交于 2019-12-22 00:47:35
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: JavaScript Event Listeners vs Event Handlers element.onload vs element.addEventListener(“load”,callbak,false) I've read this question but it's still unclear to what's the difference between <input type="button" onclick="call_function();" /> And $(function() { $("#my_button").click(function() { call_function(); }); }); <input type="button" id="my_button" /> The first one is an event handler and the second one is

In MVVM, does hooking a model item's event in the ViewModel cause a memory leak?

我怕爱的太早我们不能终老 提交于 2019-12-22 00:27:41
问题 Trying to track down some memory leaks in our WPF/MVVM app and something occurred to me... If you listen to ModelItem events in its associated ViewModel with an instance-specific handler, doesn’t that make the ViewModelItem hang around as long as the ModelItem still exists? Consider this case... public class ItemViewModel { public ItemViewModel(ModelItem item) { this.Item = item; item.SomeEvent += ItemSomeEventHandler } Public ModelItem Item{ get; private set; } // Note: This is a handler on

Add event for PictureBox mouse down

社会主义新天地 提交于 2019-12-21 22:02:25
问题 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? 回答1: 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

How to implement touch events in uiwebview?

倾然丶 夕夏残阳落幕 提交于 2019-12-21 19:56:55
问题 I have tried various solutions provided on this site and others to implement touch events on uiwebview. But still I am not able to do this. Actually, i have created a article reader application. Here, I have added a uiwebview on the normal uiview. Now, I want to trace some user touch events on that particular webview. When I do this on normal view, it works perfectly. But if I try it on webview. it stops working. The solutions I tried before are implementing touch methods like touchbegan

How do I call a function every time the DOM changes in jQuery?

浪子不回头ぞ 提交于 2019-12-21 17:01:15
问题 I need to ensure that a page stays the way my script describes even after the DOM changes; my script has to handle these changes to the DOM such that my script doesn't only handle on the initial state. Is there an event that I can use to handle these DOM changes? 回答1: Taking your question in the strictest sense, something like this: //--- Narrow the container down AMAP. $("YOUR SELECTOR").bind ("DOMSubtreeModified", HandleDOM_ChangeWithDelay); var zGbl_DOM_ChangeTimer = null; function

Invoke of an EventHandler

我的未来我决定 提交于 2019-12-21 11:32:51
问题 I have the following EventHandler: private EventHandler<MyEventArgs> _myEventHandler; public event EventHandler<MyEventArgs> MyEvent { add { _myEventHandler += value; } remove { _myEventHandler -= value; } } Could somebody explain the difference between the following snippets? Snippet EventHandler (A): //Snippet A: if (_myEventHandler != null) { _myEventHandler(new MyEventArgs()); } Snippet BeginInvoke (B): //Snippet B: if (_myEventHandler != null) { _myEventHandler.BeginInvoke(new