event-handling

What version of IE doesn't pass the event as argument to listeners?

可紊 提交于 2019-12-01 20:35:55
As some old versions of IE didn't provide the event as argument to event listeners, we got used to (event||window.event) . In order to decide whether it can still make some sense to have this in a modern library, I tried to look at what versions were concerned but I couldn't find this information. So, what's the most recent version of IE that didn't provide the event as argument ? Internet Explorer provides a global object window.event, which references the last event. And before IE9 there are no arguments in the handler. Get from 来源: https://stackoverflow.com/questions/22552338/what-version

iTextSharp - Text overlapping image

扶醉桌前 提交于 2019-12-01 20:35:46
I'm using iTextSharpText to build a PDF. I was asked to add some dynamic text over an image. I've already tried some examples that I found on this forum and other websites, but I can't seem to get this right, and it's really driving me nuts. I followed this thread ( iTextSharp Adding Text plus Barcode in a single cell? ), and tried both answers. First I tried: var img_operacao = Image.GetInstance(String.Format("{0}{1}", Settings.Default.SiteRootURL, "/PublishingImages/PDF_operacao.png")); img_operacao.ScaleToFit(150, 41); img_operacao.Alignment = Image.UNDERLYING; var ph0 = new Phrase(title0,

Stopping default behavior of events in Swing

耗尽温柔 提交于 2019-12-01 18:29:11
问题 I have the following bit of code in a method called by clicking the send button, or pressing enter in the message text field in a piece of code. // In class ChatWindow private void messageTextAreaKeyPressed(java.awt.event.KeyEvent evt) { // Event handler created by Netbeans GUI designer to call this method. if(evt.getKeyCode() == java.awt.event.KeyEvent.VK_ENTER) { sendMessage(); } } public void sendMessage() { String currentMessage = messageTextArea.getText(); addMessage("You",

Simple javascript to mimic jQuery behaviour of using this in events handlers

一曲冷凌霜 提交于 2019-12-01 17:59:20
This is not a question about jQuery, but about how jQuery implements such a behaviour. In jQuery you can do this: $('#some_link_id').click(function() { alert(this.tagName); //displays 'A' }) could someone explain in general terms (no need you to write code) how do they obtain to pass the event's caller html elments (a link in this specific example) into the this keyword? I obviously tried to look 1st in jQuery code, but I could not understand one line. Thanks! UPDATE: according to Anurag answer I decided to post some code at this point because it seems easier to code than what I thought:

Stopping default behavior of events in Swing

心不动则不痛 提交于 2019-12-01 17:55:11
I have the following bit of code in a method called by clicking the send button, or pressing enter in the message text field in a piece of code. // In class ChatWindow private void messageTextAreaKeyPressed(java.awt.event.KeyEvent evt) { // Event handler created by Netbeans GUI designer to call this method. if(evt.getKeyCode() == java.awt.event.KeyEvent.VK_ENTER) { sendMessage(); } } public void sendMessage() { String currentMessage = messageTextArea.getText(); addMessage("You", currentMessage); app.sendMessage(currentMessage, 1); messageTextArea.setText(""); } The last bit of code blanks the

How can I simulate the press of a button?

杀马特。学长 韩版系。学妹 提交于 2019-12-01 17:44:29
I want to test some forms. Is there a way to simulate the press of an Ok (or Cancel) button so that the button is pressed and fires the event handlers that are associated with it? The cleanest approach is to call the Click method of the button. This is better than the alternatives for these reasons: You could read the OnClick property, check that it was not nil, and then call the method. But that seems rather pointless since the Click method already does just that. There's no point duplicating this code. And you could call the event handler directly, but that would require your code to have

Simple javascript to mimic jQuery behaviour of using this in events handlers

与世无争的帅哥 提交于 2019-12-01 17:24:16
问题 This is not a question about jQuery, but about how jQuery implements such a behaviour. In jQuery you can do this: $('#some_link_id').click(function() { alert(this.tagName); //displays 'A' }) could someone explain in general terms (no need you to write code) how do they obtain to pass the event's caller html elments (a link in this specific example) into the this keyword? I obviously tried to look 1st in jQuery code, but I could not understand one line. Thanks! UPDATE: according to Anurag

web client DownloadFileCompleted get file name

依然范特西╮ 提交于 2019-12-01 17:23:30
I tried to download file like this: WebClient _downloadClient = new WebClient(); _downloadClient.DownloadFileCompleted += DownloadFileCompleted; _downloadClient.DownloadFileAsync(current.url, _filename); // ... And after downloading I need to start another process with download file, I tried to use DownloadFileCompleted event. void DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e) { if (e.Error != null) { throw e.Error; } if (!_downloadFileVersion.Any()) { complited = true; } DownloadFile(); } But, i cannot know name of downloaded file from

web client DownloadFileCompleted get file name

泄露秘密 提交于 2019-12-01 16:42:31
问题 I tried to download file like this: WebClient _downloadClient = new WebClient(); _downloadClient.DownloadFileCompleted += DownloadFileCompleted; _downloadClient.DownloadFileAsync(current.url, _filename); // ... And after downloading I need to start another process with download file, I tried to use DownloadFileCompleted event. void DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e) { if (e.Error != null) { throw e.Error; } if (!_downloadFileVersion.Any()) {

Why use event listeners over function calls?

拥有回忆 提交于 2019-12-01 16:16:47
I've been studying event listeners lately and I think I've finally gotten them down. Basically, they are functions that are called on another object's method. My question is, why create an event listener when calling the function will work just fine? Example, I want to call player.display_health(), and when this is fired, the method player.get_health() should be fired and stored so that display_health() has access to it. Why should I use an event listener over simply calling the function? Even if display_health() were in another object, this still doesn't appear to be a problem to me. If you