event-handling

How do you get the control that was clicked to open a ContextMenuStrip?

佐手、 提交于 2019-11-29 04:01:18
I'm using a ContextMenuStrip for multiple controls and I'm trying to figure out the best way to get the control that was actually clicked on to open the Context Menu. The sender just gives the ToolStripMenuItem reference, which has an Owner property that references the ContextMenuStrip , but I cannot figure out how to tell which control the click came from. There must be a simple way to check this, right? I'm checking it in the ToolStripMenuItem 's click event. Friend WithEvents mnuWebCopy As System.Windows.Forms.ToolStripMenuItem ... Private Sub mnuWebCopy_Click(ByVal sender As Object, ByVal

Can i access outer class objects in inner class [duplicate]

我的未来我决定 提交于 2019-11-29 03:08:32
This question already has an answer here: What's the best way of accessing field in the enclosing class from the nested class? 8 answers I have three classes like this. class A { public class innerB { //Do something } public class innerC { //trying to access objB here directly or indirectly over here. //I dont have to create an object of innerB, but to access the object created by A //i.e. innerB objInnerB = objB; //not like this innerB objInnerB= new innerB(); } private innerB objB{get;set;} **//Private** public A() { objB= new innerB(); } } I want to access the object of class B in Class C

How do I add Page Events for ASP.NET in Visual Studio 2008

安稳与你 提交于 2019-11-29 03:06:14
问题 This is a bit of a Visual Studio question. I feel with all the helpful Intellisense there should be something to assist but I can't seem to find it. I made a page with a codebehind in ASP.NET C# in VS2008 and it autogenerates a PageLoad event method, of course. Well, what if I want to add methods for more events besides PageLoad? I would think there would be some list on the Foo.aspx page of possible method event handlers to add. Aren't there more maybe like PageInit, PageDispose, (or equiv)

Qt event loop and unit testing?

会有一股神秘感。 提交于 2019-11-29 03:03:57
I'we started experimenting with unit testing in Qt and would like to hear comments on a scenario that involves unit testing signals and slots. Here is an example: The code i would like to test is (m_socket is a pointer to QTcpSocket ): void CommunicationProtocol::connectToCamera() { m_socket->connectToHost(m_cameraIp,m_port); } Since that is an asynchronous call i can't test a returned value. I would however like to test if the response signal that the socket emits on a successful connection ( void connected () ) is in fact emitted. I've written the test below: void CommunicationProtocolTest:

Detect focus initiated by tab key?

北慕城南 提交于 2019-11-29 02:49:31
I want to detect the focus event of an element, but only if it was initiated by the user pressing the tab key. For example: <input type="text" id="foo" /> <input type="text" id="detect" /> If the user is focused on #foo and presses Tab , I want the event to fire once #detect becomes focused (or a conditional inside the focus event to be true). Conversely, if the user simply clicks on the #detect field to focus it, I do not want the event to fire (or I want the conditional inside the focus event call to be false). I don't want to use the keydown event of #foo and check if the tab key was

Resize elements by dragging divider handler

允我心安 提交于 2019-11-29 02:45:31
I want to be able to drag a divider up and down to resize the divs above and below the divider on a fixed page height. These divs could be in a table, although they need not be. In short, I would like to be able to emulate what happens on the jsFiddle site, although I only need the vertical resize. jsFiddle have used mooTools, but I want to do it with jQuery. One important complication: I won't know the size of the div above the divider until it is actually built dynamically, so I can't just start with a set absolute positioning. What is the best way forward? I have a feeling I'll just be

Hide MAAttachedWindow when clicking outside

最后都变了- 提交于 2019-11-29 02:44:15
I'm using an MAAttachedWindow to display a custom window under a NSStatusItem in the Menubar. Everything works fine, but I can't find an easy way to hide it when the user clicks outside of the window. I want to implement this behavior because it's what the user expects. This is the code used to display the MAAttachedWindow : - (void)toggleAttachedWindowAtPoint:(NSPoint)pt { if (!self.attachedWindow) { self.attachedWindow = [[MAAttachedWindow alloc] initWithView:logView attachedToPoint:pt inWindow:nil onSide:MAPositionBottom atDistance:5.0]; [self.attachedWindow setLevel:kCGMaximumWindowLevel];

C# Drag and Drop From listBox

▼魔方 西西 提交于 2019-11-29 02:38:20
I'm trying to build a simple interface that allows users to drop files into a listBox to add them to a process, and to drag them out to remove them. Everything is working fine, but I'd like to add one feature to make it just a tad more sophisticated. Right now, I have the removal of the item tied to the DragLeave event, which means that as soon as the mouse leaves the box, the item is removed. But I'd like for users to be able to change their minds. In other words, if they realize they're dragging the wrong file out, I'd like them to be able to move the mouse back into the listBox and release

Javascript - detect if event lister is supported

冷暖自知 提交于 2019-11-29 02:34:56
问题 Is it possible to detect if certain events are supported in certain browsers? I can detect if the browser supports document.addEventListener, but I need to know if it supports the event DOMAttrModified. Firefox and Opera support it, but Chrome and others do not. Thanks if anyone can help! 回答1: Updated answer : Yes , you can feature-detect this. Create an element, listen for the event, and change an attribute on the element. In my tests, you don't even have to add the element to the DOM tree,

How do I attach an event handler to a panel in extJS?

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-29 02:19:02
All I want to do is handle a click on an extJS panel . I've tried all the of suggestions on this question plus all I could find elsewhere but each of them fail in the ways described below. What is the correct syntax to add a click event handler to a extJS panel? [ Edit : For the sake of others who may find this question later, I'll add some comments inline to make this easier to decipher --@bmoeskau] doesn't execute handler: var menuItem1 = new Ext.Panel({ id: 'panelStart', title: 'Start', html: 'This is the start page.', cls:'menuItem', listeners: { click: function() { alert('ok'); } } });