Search Results

Search found 12948 results on 518 pages for 'mouse events'.

Page 130/518 | < Previous Page | 126 127 128 129 130 131 132 133 134 135 136 137  | Next Page >

  • equality on the sender of an event

    - by Berryl
    I have an interface for a UI widget, two of which are attributes of a presenter. public IMatrixWidget NonProjectActivityMatrix { set { // validate the incoming value and set the field _nonProjectActivityMatrix = value; .... // configure & load non-project activities } public IMatrixWidget ProjectActivityMatrix { set { // validate the incoming value and set the field _projectActivityMatrix = value; .... // configure & load project activities } The widget has an event that both presenter objects subscribe to, and so there is an event handler in the presenter like so: public void OnActivityEntry(object sender, EntryChangedEventArgs e) { // calculate newTotal here .... if (ReferenceEquals(sender, _nonProjectActivityMatrix)) { _nonProjectActivityMatrix.UpdateTotalHours(feedback.ActivityTotal); } else if (ReferenceEquals(sender, _projectActivityMatrix)) { _projectActivityMatrix.UpdateTotalHours(feedback.ActivityTotal); } else { // ERROR - we should never be here } } The problem is that the ReferenceEquals on the sender fails, even though it is the implemented widget that is the sender - the same implemented widget that was set to the presenter attribute! Can anyone spot what the problem / fix is? Cheers, Berryl I didn't know you could edit nicely. Cool. Here is the event raising code: void OnGridViewNumericUpDownEditingControl_ValueChanged(object sender, EventArgs e) { // omitted to save sapce if (EntryChanged == null) return; var args = new EntryChangedEventArgs(activityID, dayID, Convert.ToDouble(amount)); EntryChanged(this, args); } Here is the debugger dump of the presenter attribute, sans namespace info: ?_nonProjectActivityMatrix {WinPresentation.Widgets.MatrixWidgetDgv} [WinPresentation.Widgets.MatrixWidgetDgv]: {WinPresentation.Widgets.MatrixWidgetDgv} Here is the debugger dump of the sender: ?sender {WinPresentation.Widgets.MatrixWidgetDgv} base {Core.GUI.Widgets.Lookup.MatrixWidgetBase<Core.GUI.Widgets.Lookup.DynamicDisplayDto>}: {WinPresentation.Widgets.MatrixWidgetDgv} _configuration: {Domain.Presentation.Timesheet.Matrix.WeeklyMatrixConfiguration} _wrappedWidget: {Win.Widgets.DataGridViewDynamicLookupWidget} AllowUserToAddRows: true ColumnCount: 11 Count: 4 EntryChanged: {Method = {Void OnActivityEntry(System.Object, Smack.ConstructionAdmin.Domain.Presentation.Timesheet.Matrix.EntryChangedEventArgs)}} SelectedCell: {DataGridViewNumericUpDownCell { ColumnIndex=3, RowIndex=3 }} SelectedCellValue: "0.00" SelectedColumn: {DataGridViewNumericUpDownColumn { Name=MONDAY, Index=3 }} SelectedItem: {'AdministrativeActivity: 130-04', , AdministrativeTime, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00} Berryl

    Read the article

  • Thread-safe queue in Javascript or jQuery

    - by at
    I have many asynchronous AJAX calls whose results will get processed. It doesn't matter what order the processing occurs, but the results need to get processed one at a time. So I'd like to simple do my AJAX calls and they all just put their results in a single queue. That queue should then get processed on a single thread. This way the results get processed one at a time as soon as possible. What's the best way to do this? I'm using jQuery, so happy to take advantage of any facilities it provides for this.

    Read the article

  • javascript: capturing load event on LINK

    - by pgn
    hello everyone, i'm trying to attach an event handler to the load event of a link tag, to execute some code after a stylesheet has loaded. new_element = document.createElement('link'); new_element.type = 'text/css'; new_element.rel = 'stylesheet'; new_element.href = 'http://domain.tld/file.css'; new_element.addEventListener('load', function() { alert('foo'); }, false); document.getElementsByTagName('head')[0].appendChild(new_element) i have tried onreadystatechange as well new_element.onreadystatechange = function() { alert('foo'); } unfortunately neither approach results in an alert being triggered.. Furthermore, new_element.onload is null after registering a handler for the 'load' event with addEventListener.. is that normal? thanks, andrew ps: i may not use any framework in solving this

    Read the article

  • Extending a jquery plugins event callback

    - by Greg J
    I'm extending the functionality of a jquery plugin (foo) with another jquery plugin (bar). Essentially, the first plugin specifies an onReady(): var foo = $.foo({ onReady: function() { alert('foo'); }}); Foo is sent to bar as a parameter to bar: var bar = $.bar(foo); I want bar to be able to hook into foo's onReady event: (function($) { $.extend({ bar: function(foo) { var foo = foo; // How to do alert('bar') when foo.onready is called? } }); })(jQuery); I can override foo's onready event: foo.onready = function() { alert('bar'); } But I don't want to override it, I want to extend it so that I'll see both alerts when foo is ready. Thanks in advance!

    Read the article

  • Can I interrupt javascript code and then continue on a keystroke?

    - by Brian Ramsay
    I am porting an old game from C to Javascript. I have run into an issue with display code where I would like to have the main game code call display methods without having to worry about how those status messages are displayed. In the original code, if the message is too long, the program just waits for the player to toggle through the messages with the spacebar and then continues. This doesn't work in javascript, because while I wait for an event, all of the other program code continues. I had thought to use a callback so that further code can execute when the player hits the designated key, but I can't see how that will be viable with a lot of calls to display.update(msg) scattered throughout the code. Can I architect things differently so the event-based, asynchronous model works, or is there some other solution that would allow me to implement a more traditional event loop? Am I making sense? Example: // this is what the original code does, but obviously doesn't work in Javascript display = { update : function(msg) { // if msg is too long // wait for user input // ok, we've got input, continue } }; // this is more javascript-y... display = { update : function(msg, when_finished) { // show part of the message $(document).addEvent('keydown', function(e) { // display the rest of the message when_finished(); }); } }; // but makes for amazingly nasty game code do_something(param, function() { // in case do_something calls display I have to // provide a callback for everything afterwards // this happens next, but what if do_the_next_thing needs to call display? // I have to wait again do_the_next_thing(param, function() { // now I have to do this again, ad infinitum } }

    Read the article

  • IPhone Objectvie C

    - by Sea
    I am trying to determine if a UILabel was touched and if so do something. Give .. . . . UILabel * site = [[UILabel alloc] initWithFrame:CGRectMake(0, 185, 320, 30)]; site.text = [retriever.plistDict valueForKey:@"url"]; site.textAlignment =UITextAlignmentCenter; site.backgroundColor = [UIColor clearColor]; site.textColor = [UIColor whiteColor]; site.userInteractionEnabled = YES; [theBgView addSubview:site]; [site release]; . . . Then I write the callback. - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{ retriever = [PListRetriever sharedInstance]; CGPoint pt = [[touches anyObject] locationInView: self]; NSURL *target = [[NSURL alloc] initWithString:[retriever.plistDict valueForKey:@"url"]]; [[UIApplication sharedApplication] openURL:target]; } The problem is right now, no matter where I touch in the View the Url is being opened. How do I determine if only just my label was touched?

    Read the article

  • jQuery .val Enigma between two input boxes

    - by Matt
    I'm trying to get it so that if I move a red div-square around the screen using jQuery UI and jQuery, then an input field updates with the position of the div. I got that working with a simple .val. But, it's hard to explain why, but I need to make it so that when I move the square, it updates my input box, and when the input box value is changed, another input box reflects the new value of the old input box. Do I make any sense, coz I'm confusing myself :). I made a jsfiddle, so perhaps it'll make more sense there. If you move the red square, then the input box directly above it updates, but the input box above that does not, even though it is programmed to reflect the value of the input box below itself. P.S. Is this specific to only jQuery, or is this problem present in all of JavaScript. Thanks! http://jsfiddle.net/xmCsq/27/

    Read the article

  • Javascript Close Browser or goto external site function

    - by aaroninfidel
    Hello, I've been trying to figure out how I can go about creating a javascript function that will only be called when a user is accessing an external site or closing the window to the current site they're on. So far I've come up with this, any help is greatly appreciated. <script type="text/javascript"> window.onbeforeunload = confirmExit; function getAd() { var myAds = new Array(); myAds[0] = "http://localhost/link1"; myAds[1] = "http://localhost/link2"; var randomAd = Math.floor(Math.random() * myAds.length); return myAds[randomAd]; } function confirmExit(){ alert(getAd()); return false; } </script>

    Read the article

  • how to stop onChange in javascript

    - by shrimpy
    in one of my selection box, i have a onChange="..." specified... coz i want to change some other form value after any selection changes. however ... in the same page, some wired case i have to manually set the value.. so i have to use some javascript to set the value of the selection combox, but in this case, i don`t want that onChange event to be fired... how can i walk around it??? Forgot to mention that i am actually using dijit.form.comboBox. for normal HTML form comboBox, it won`t cause any issue. Only i use the dijit comboBox, and i try to set the value to some other value, dojo will trigger the onChange.

    Read the article

  • Change button's enabled property via checkbox

    - by Ivan Stoyanov
    I tried this javascript but it doesn't work - here I need to change the button's enabled property to true when the checkbox is checked and to false when it isn't. This is my code. <tr> <td colspan="2" align="center"> <asp:CheckBox ID="cbAcceptAgreement" runat="server" OnClientClick="acceptAgreement(this)" /> <asp:Label ID="lblUserAgreement" runat="server" Text="I accept the " /> <asp:HyperLink ID="hlUserAgreement" runat="server" Text="User Agreement" NavigateUrl="Help/UserAgreement.aspx" /> </td> </tr> <tr> <td colspan="2" align="center"> <asp:Button ID="btnRegister" runat="server" Text="Register" /> </td> </tr> <script type="text/javascript"> function acceptAgreement(Obj) { document.getElementById('<%=btnRegister.ClientID%>').disabled = !obj.checked; } </script> Can you help me solve this problem?

    Read the article

  • Transform any JavaScript function into a page event

    - by Laith
    I need to be able to achieve the following (one way or another): function ShowContent() {} document.onShowContent = function () { // anything I want to happen.... } What I'm trying to do is to add a kind of listener to me Advertisement code on the page that will auto refresh the ad slot when a specific function is called. Instead of having that function "ShowContent()" directly refresh the ad code, I want the ad code to refresh if it detects that "ShowContent()" has been called. Thanks.

    Read the article

  • How do I make sure no handlers are attached to an event?

    - by Edward Tanguay
    I am adding an event handler like this: theImage.MouseMove += new MouseEventHandler(theImage_MouseMove); but in my application, this code gets run every time the page is shown, so I want to attach the event handler only once, but how can I tell if a handler has been set yet or not, something like this: if(theImage.MouseMove == null) //error theImage.MouseMove += new MouseEventHandler(theImage_MouseMove);

    Read the article

  • IE not triggering keyboard event on a form with ONE FIELD

    - by raj
    I'm seeing my Friend's code here... <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE> Check action </TITLE> <script> function detectEvent(){ if(window.event.keyCode==13) { alert("you hit return!"); } } </script> </HEAD> <BODY> <form name="name1" onkeyup="detectEvent()" action="page2.html"> <p> Field1 <input type="text" id="text1"/> </p> </form> </BODY> </HTML> and when he tried entering a value in the textbox and pressed enter, it did not call the detectEvent(). I said, it'll always call onSubmit on enter button..... and he surprised me, <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE> Check action </TITLE> <script> function detectEvent(){ if(window.event.keyCode==13) { alert("you hit return!"); } } </script> </HEAD> <BODY> <form name="name1" onkeyup="detectEvent()" action="page2.html"> <p> Field1 <input type="text" id="text1"/> </p> <p> Field1 <input type="text" id="text2"/> </p> </form> </BODY> </HTML> Now press enter, The function gets called..... Why so!? Why onKeyUp not called on forms with just one field.!!! am i missing something?

    Read the article

  • Prototype to JQuery - how to access originator of event

    - by ciaranarcher
    Hi there I'm coming from a Prototype background and looking into JQuery. I'd like to know the 'right' way to do attach a click event to a bunch of elements, but then know in the event handler which one of my elements was clicked. I've come up with the following: MYNS.CarouselHelper.prototype.attachImgHandlers = function () { $j(".carouselItem").bind("click", this, function(e){ e.data.openCarouselImage(e) }); } I then have the following in my event handler: MYNS.CarouselHelper.prototype.openCarouselImage = function(e) { var img = e.currentTarget; // Do stuff to the image element }; Is this 'right'? It feels wrong to me as I am used to explicitly passing the element to the event handler in Prototype as I loop through an array of elements. Thanks in advance.

    Read the article

  • Event problems with FF

    - by s4v10r
    Hi all :) Made this sweet little script to auto change fields after input. Works nicely in IE, Chrome and Safari, but not in FF or opera. JS code: function fieldChange(id, e){ var keyID = (window.event) ? event.keyCode : e.keyCode; if (document.getElementById(id).value.length >= 2){ if (keyID >= 48 && keyID <= 57 || keyID >= 96 && keyID <= 105){ switch(id){ case "textf1": document.getElementById("textf2").focus(); break; case "textf2": document.getElementById("textf3").focus(); break; case "textf3": if (document.getElementById(id).value.length >= 4){ document.getElementById("nubPcode").focus(); } break; } } } HTML: <div class="privateOrderSchema"> <input type="text" id="textf1" name="textf1" maxlength="2" size="4" onKeyUp="fieldChange('textf1')"/>- <input type="text" id="textf2" name="textf2" maxlength="2" size="4" onKeyUp="fieldChange('textf2')" />- <input type="text" id="textf3" name="textf3" maxlength="4" size="5" onKeyUp="fieldChange('textf3')" /> </div> <div class="privateOrderSchema"> <input type="text" id="nubPcode" name="nubPcode" size="4" maxlength="4" /> <br /> </div> Does anybody know how to send the "e" var in this scenario? Tnx all :D ur gr8!

    Read the article

  • Changing <img src="XXX" />, js event when new image has finished loading?

    - by carillonator
    I have a photo gallery web page where a single <img src="XXX" /> element's src is changed (on a click) with javascript to show the next image—a poor man's ajax I guess. Works great on faster connections when the new image appears almost immediately. Even if it takes a few seconds to load, every browser I've tested it on keeps the old image in place until the new one is completely loaded. It's a little confusing waiting those few seconds on a slow connection, though, and I'm wondering if there's some javascript event that fires when the new image is done loading, allowing me to put a little working... animated gif or something up in the meantime. I know I could use AJAX for real (I'm using jQuery already), but this is such a nice and simple solution. Besides this lag, is there any other reason I should stay away from this approach to changing images? thanks.

    Read the article

  • Table data display in HTML

    - by Hulk
    In the following table how to adjust the height and width automatically for the table. i.e, if the data is more it should display all the data else present data ina fashionable manner <table="mytable"> <tr><td>more data.............................................................................</td> <td>a</td> </tr> In the nothing should be wrapped wither in case of large chuks of data or small chunks of data. Thanks....

    Read the article

  • Preventing focus on next form element after showing alert using JQuery

    - by digitalsanctum
    I have some text inputs which I'm validating when a user tabs to the next one. I would like the focus to stay on a problematic input after showing an alert. I can't seem to nail down the correct syntax to have JQuery do this. Instead the following code shows the alert then focuses on the next text input. How can I prevent tabbing to the next element after showing an alert? $('input.IosOverrideTextBox').bind({ blur: function(e) { var val = $(this).val(); if (val.length == 0) return; var pval = parseTicks(val); if (isNaN(pval) || pval == 0.0) { alert("Invalid override: " + val); return false; } }, focus: function() { $(this).select(); } });

    Read the article

  • C# How can I trigger an event at a specific time of day?

    - by Andrei
    Hello everybody. I'm working on a program that will need to delete a folder (and then re-instantiate it) at a certain hour of the day, and this hour will be given by the user. The hour will most likely be during the night, because that's when nobody is accessing the folder (it's outside working hours). Is there a way to trigger that event at that certain hour? I know about timers, but is there an easier way to do this without a timer that ticks and checks to see what time it is? Thanks.

    Read the article

  • What's the problem of this piece of JavaScript code?

    - by Yousui
    Hi guys, The following piece of JavaScript code is a cross browser way to add/remove event handler. It will save a deleting method as a property of an HTML element object. Now it works well in FireFox but not in IE6. I can't find out why so I came here for help. Great thanks. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <title>pop</title> </head> <body> <input type="text" name="input1" id="input1" value="" /> <div id="result"> </div> <div id="result2" style="width:200px;height:100px;border:1px solid red;"> </div> <button id="stop" name="stop">click me</button><button id="stop2" name="stop2">click me</button> <script type="text/javascript" charset="utf-8"> function handler(e){ e = e || window.event; var key_code = e.keyCode || e.charCode || e.which, source = e.srcElement || e.target; document.getElementById("result").innerHTML = "" + key_code; } function handler2(e){ e = e || window.event; var key_code = e.keyCode || e.charCode || e.which, source = e.srcElement || e.target; document.getElementById("result2").innerHTML = e.button; } function add_event(o, event_type, callback, capture){ o = typeof o === "string" ? document.getElementById(o) : o; if(document.addEventListener){ add_event = function(o, event_type, callback, capture){ o = typeof o === "string" ? document.getElementById(o) : o; capture = typeof(capture) === "undefined" ? false : true; o.addEventListener(event_type, callback, capture); o.removes = o.removes || {}; o.removes[event_type] = function(){ o.removeEventListener(event_type, callback, capture); }; if(!o.remove_event){ o.remove_event = function(type){ if(typeof type === "undefined"){ return; } o.removes[type](); } } } }else if(document.attachEvent){ add_event = function(o, event_type, callback, capture){ o = typeof o === "string" ? document.getElementById(o) : o; capture = typeof(capture) === "undefined" ? false : true; o.attachEvent(event_type, callback); o.removes = o.removes || {}; o.removes[event_type] = function(){ o.detachEvent(event_type, callback); } if(!o.remove_event){ o.remove_event = function(type){ if(typeof type === "undefined"){ return; } o.removes[type](); } } } } add_event(o, event_type, callback, capture); } add_event("input1", "keyup", handler); add_event("input1", "click", handler2); add_event("stop", "click", function(){ document.getElementById("input1").remove_event("keyup"); }); add_event("stop2", "click", function(){ document.getElementById("input1").remove_event("click"); }); </script> </body> </html>

    Read the article

  • Is there a way to TouchEndInside in Mobile Safari?

    - by Ken Sykora
    I'm trying to determine whether a users does a touchupinside in mobile safari for an iPhone web app. So far I've been unsuccessful. touchend event fires regardless of where the touchup event happens on the screen, and I can't seem to discern that the target has changed by anything in the event argument. Can anyone point me in the right direction on how to capture a touchendinside (vs. touchendoutside) event using javascript? $('a.arrow').bind('touchend',function(e) { console.log($(e.srcElement)); //both of these always return the same element console.log($(e.toElement)); //both of these always return the same element });

    Read the article

  • Javascript click function not working

    - by Nabe
    I need to null the value in text box on click, currently I have written a code as such <div class="keyword_non"> <h1>Keywords : <a class="someClass question_off" title="Keywords "></a></h1> <h2><input type="text" name="kw1" value="one" /></h2> <h2><input type="text" name="kw2" value="two" /></h2> <h2><input type="text" name="kw3" value="three" /></h2> <h2><input type="text" name="kw4" value="four" /></h2> </div> <script type="text/javascript" src="/functions/javascript/custom/non_profit_edit.js"></script> <script type="text/javascript" src="/functions/javascript/jquery-1.7.1.min.js"></script> <script type="text/javascript" src="/functions/javascript/custom/jquery-ui-1.8.7.custom.min.js"></script> Inside non_profit_edit.js i have written as such $(document).ready(function(){ $(".kw1").click(function() { $(".kw1").val(" "); }); $(".kw2").click(function() { $(".kw2").val(" "); }); $(".kw3").click(function() { $(".kw3").val(" "); }); $(".kw4").click(function() { $(".kw4").val(" "); }); }); But write now its not working properly... Is this any browser issues or error in code..

    Read the article

< Previous Page | 126 127 128 129 130 131 132 133 134 135 136 137  | Next Page >