event-handling

Strange Async Warning in VS 2013

余生颓废 提交于 2019-12-13 06:53:15
问题 I have a Button on a UserControl . I'm marking the UserControl 's Click event handler for the Button as Async , so I can run an asynchronous method from inside it. I have to do it this way, otherwise the UI blocks and a ToolStripLabel on the Form doesn't get updated before the SchedulerNode.Load() method is called. Visual Studio isn't liking it very much, but the warning it's returning seems both incorrect and misapplied. Here's the code: And here's the warning: Note that VS indicates the

Accessing every document that a user currently views from an extension

孤人 提交于 2019-12-13 06:35:13
问题 I'm writing an extension that checks every document a user views on certain data structures, does some back-end server calls and displays the results as a dialog.The problem is starting and continuing the sequence properly with event listeners. My actual idea is: Load: function() { var Listener = function(){ Fabogore.Start();}; var ListenerTab = window.gBrowser.selectedTab; ListenerTab.addEventListener("load",Listener,true); } (...) ListenerTab.removeEventListener("load", Listener, true);

How to handle mouse events in Qt?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-13 06:08:09
问题 Dragging, panning and mouse tracking items in Qt scene are the 3 actions which I want to simultaneously use in my app. However, it is more difficult than I thought. Example code : from PySide.QtCore import * from PySide.QtGui import * class View(QGraphicsView): """# HOW TO ATTACH MOUSE EVENTS PROGRAMMATICALLY ? def mouseMoveEvent(self, event): print "View MOVE", event.pos() """ class Scene(QGraphicsScene): pass class CircleForTrackingSwitch(QGraphicsEllipseItem): def __init__(self, scene):

CAsyncSocket not firing events?

南楼画角 提交于 2019-12-13 06:06:09
问题 i have implemented my ClientSocket class from CAsyncSocket: class ClientSocket : public CAsyncSocket { // this socket sends data back to "backSocket" which points to this only for // testing but it can send data to other sockets like that too. ClientSocket * backSocket; // store some data in backupData untill connection is established. StringBuilder * backupData; public: virtual void OnClose(int); virtual void OnReceive(int); ClientSocket(void); bool ConnectToBACK(); virtual ~ClientSocket

Why does the “.on(<event>, function())” style of jQuery event handler not work for “hover”?

北城以北 提交于 2019-12-13 05:53:27
问题 Both of these .hover(function() {...}, function() {...}) using either the element ID or this work: $( "#imgPostTravel" ).hover(function() { $('#imgPostTravel').addClass('popout_image'); $('#imgPostTravel').addClass('shadow'); }, function() { $('#imgPostTravel').removeClass('popout_image'); $('#imgPostTravel').removeClass('shadow'); }); $( "#imgPostTravel" ).hover(function() { $(this).addClass('popout_image'); $(this).addClass('shadow'); }, function() { $(this).removeClass('popout_image'); $

Compiler complains when Event has add & remove properties. Compiles OK without

白昼怎懂夜的黑 提交于 2019-12-13 04:48:23
问题 I'm modeling my C# 4.0 event handler logic after this SO answer and get the error ThresholdExceededEvent can only appear on the left hand side of += or -= Code private EventHandler<EventLogAlert> thresholdExceededEventDelegate; public event EventHandler<EventLogAlert> ThresholdExceededEvent { add { thresholdExceededEventDelegate += value; Console.WriteLine("add operation"); } remove { thresholdExceededEventDelegate -= value; Console.WriteLine("remove operation"); } } protected virtual void

Event Handlers & Event Listeners Independent of one Another?

我们两清 提交于 2019-12-13 04:22:24
问题 I have a question in regards to an aspect of event-driven programming. I am not sure whether the code for event handlers and event listeners should be completely independent from each other. From my understanding, event listeners are attached to some type of application (let's say a GUI), and their only responsibility is to capture user input. A message dispatcher then captures that event, and sends it to the appropriate event handler. So, it seems to me that dependencies should not exist

How to disable a key when a button is focused

我的梦境 提交于 2019-12-13 04:19:15
问题 How to disable the up arrow key when a button is focused and enable it when the button is not focused in angular2? For example: In html: <button type="button" (focus)="disableUpArrowKey()"> In script: disableUpArrowKey(){ //?? } 回答1: Bind on keydown and call preventDefault of event. html: <button (keydown)="onKeydown($event)">Button</button> ts: ... onKeydown(event: KeyboardEvent) { if (event.key === 'ArrowUp') { event.preventDefault() } } ... stackblitz : https://stackblitz.com/edit/angular

Jquery .off and then restore it to on

寵の児 提交于 2019-12-13 03:55:24
问题 When i want to remove the click handler from my submit button,I am using $(#submitBtn).off();//works fine But,when I want to restore back to its previous stage, .on() doesnt work. if(flag){ $(#submitBtn).off();//works fine $.ajax({ type: 'POST', url: 'someservice.php', data: {email:email,name:name,text:text}, success: function (data) { $('#submitBtn').on();//does not work });//ajax end } 回答1: .off() Calling .off() with no arguments removes all handlers attached to the elements. Specific event

C# Dynamic template implicit conversion error from System.EventHandler to System.EventHandler<TEventArgs>

徘徊边缘 提交于 2019-12-13 03:48:07
问题 Code: public void InstantiateIn(System.Web.UI.Control container) { PlaceHolder ph = new PlaceHolder(); SectionArgs e = new SectionArgs(); ph.DataBinding += new EventHandler<SectionArgs>(ItemTemplate_DataBinding); container.Controls.Add(ph); } static void ItemTemplate_DataBinding(object sender, SectionArgs e) { PlaceHolder ph = (PlaceHolder)sender; } Error: Cannot implicitly convert type 'System.EventHandler<UserControlLibrary.Section.ItemTemplate.SectionArgs>' to 'System.EventHandler' 回答1: