event-handling

Is it possible for Global Execution Context to pop off the execution stack?

瘦欲@ 提交于 2019-12-03 13:20:56
When JS code starts to run, the Global Execution Context is created and sits at the bottom of the execution stack as to "accomodate" Global Variable Object and 'this' . If it is the case for the execution stack to get empty after the whole JS code is run and there is no Global Execution Context, how are we still able to access the global variables (for example, I am running an html file with its JS code and after its completion, I am still able to see the values of global variables through Chrome console...) or how this still points to global object (there shouldn't be any 'this' if there wasn

Events and event handling under the hood

我的梦境 提交于 2019-12-03 13:08:10
问题 I've just been working through some simple programs using SDL and it made me think back to some Java GUIs I've written. In the simple SDL programs, I have a loop that checks for any events (keypresses, mouse clicks etc...) and reacts to them. Essentially it's polling for input. In Java, you attach listeners to the GUI objects and the listeners get triggered when certain events occur. My question is, does Java just handle this polling loop in the background for us and work out things like

One Liner: WeakReference-to-a-Lambda Event Handler

别等时光非礼了梦想. 提交于 2019-12-03 13:05:52
Can you see downsides to this one-liner other than the fact that multiple uses of it would violate the DRY principle? It seems straightforward but the fact that I haven't seen others propose it makes me wonder if there's a downside to it. This bit of code creates a WeakReference to a method and then registers an event handler that invokes the reference's target. SomeEvent += (sender, e) => ((Action)(new WeakReference((Action)ProcessEvent)).Target)(); Thanks, Ben I don't think that pattern does what you expect. Are you trying to prevent the event from holding a reference to the current object

What's the difference between passing this vs. ClassName.this from an event handler when passed to Intent constructor?

痴心易碎 提交于 2019-12-03 12:57:24
In the earlier Android Programming Tutorial, page 192, we see an implementation of LunchList#onOptionsItemSelected . Within this implementation we see two Intent s passed to startActivity : one whose constructor is passed LunchList.this , the other whose constructor is passed this . What's the difference? See lines 78 - 91 here . Note how onOptionsItemSelected is not declared within an inner class. In Android/Java does the value of this change within the context of event handlers or function binding via reflection? Could both Intent instances be passed this ? In Java, this refers to the

How to detect when the form is being maximized?

こ雲淡風輕ζ 提交于 2019-12-03 12:54:49
I would like to detect when the form is going to be maximized to save certain settings (not related to the size nor position) and modify the size and position a little bit. Is there an universal way to do it ? I've tried to catch the WM_SYSCOMMAND message like in this article . It works well for maximization from menu, by maximize button, but it's not fired when I press the WIN + UP keystroke. Does anyone know an universal way how to catch the maximization event including the case with WIN + UP keystroke ? Thanks You can use the WM_GETMINMAXINFO message to save the state of the window and then

Jasmine can't spy on event handler?

百般思念 提交于 2019-12-03 12:49:47
Trying to test that an event handler gets called on a clicked element with Jasmine. Have a "Pad" object that contains a DOM element "PadElement", which gets clicked. The event handler is a method on the Pad object: GRAPH.Pad = function(graphDiv, graph) { this.graph = graph; this.clickHandler = function(e) { console.log('padElement clickHandler called'); //this.graph.createVertex(e.clientX, e.clientY); }; this.padElement = GRAPH.padElement(graphDiv, this.clickHandler); } GRAPH.padElement = function(graphDiv, clickHandler) { //Initialize pad var NS="http://www.w3.org/2000/svg"; var pad=document

How can one detect copying a link in a browser?

荒凉一梦 提交于 2019-12-03 11:42:57
Yesterday I had a chat with a taxi driver and upon mentioning that I am a programmer, he told me that a couple of days earlier he had experienced the following: upon trying to copy the URL from the address bar of his browser, a messagebox appeared with a message like "Please don't copy this link, rather register" . I am not a web developer, so this might be a lame question :-) but I wonder how such a thing is accomplished? What technology or language gives one this level of control over the events within the browser? The site was some sort of a movie downloading service, as far as I understood

How to set the Java default button to react on ENTER key _released_?

主宰稳场 提交于 2019-12-03 11:34:03
问题 In my application I use a Default button. I want it to react when ENTER Key is released . Not when ENTER Key is pressed . I removed the KeyStroke from InputMap of the button. But it didn't work for me. How should i do that? import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; public class ButtonTest { public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { @Override public void run() { buildFrame(); } }); } private static void buildFrame() {

Is it bad practice to write inline event handlers

。_饼干妹妹 提交于 2019-12-03 10:24:40
问题 Is it bad practice to write inline event handlers ? For me, I prefer use it when I want to use a local variable in the event handler like the following: I prefer this: // This is just a sample private void Foo() { Timer timer = new Timer() { Interval = 1000 }; int counter = 0; // counter has just this mission timer.Tick += (s, e) => myTextBox.Text = (counter++).ToString(); timer.Start(); } Instead of this: int counter = 0; // No need for this out of Boo & the event handler private void Boo()

Funky jQuery mouseleave behavior

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-03 10:03:32
问题 I have a menu-like drop down container that hides via binding the "mouseleave" event. <div id="container"> <select> <option>1</option> <option>2</option> <option>3</option> <option>4</option> <option>5</option> </select> </div> The problem I am having is when my container's child elements contain a SELECT object where the OPTIONS of the SELECT physically extend outside the bounds of the container. Consequently, hovering over the OPTIONS outside of the bounds trigger the "mouseleave" event to