Search Results

Search found 461 results on 19 pages for 'eventhandler'.

Page 2/19 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Tree item edit event listener in flex

    - by Biroka
    I want to catch itemEditEnd in a tree control, but i'm having a little trouble. I call the item editing a bit different: <mx:Tree id="tree" width="100%" height="100%" itemDoubleClick="treeProjects_itemDoubleClickHandler(event)" doubleClickEnabled="true" editable="true" itemEditBeginning="treeProjects_itemEditBeginingHandler(event)" itemEditEnd="treeProjects_itemEditEndHandler(event)" > but: protected function treeProjects_itemEditBeginingHandler(event:ListEvent):void { event.preventDefault(); } i do this, because I want to edit the field just when clicking rename in the context menu. And when I click rename in the context menu, this is what i'm doing (contextParentItem is the event catched on itemRollOver in the tree) : Tree( contextParentItem.target ).editedItemPosition = { columnIndex: 0, rowIndex: contextParentItem.rowIndex }; Thisway I can't catch the itemEditEnd event, but I want to handle some stuff, like: if the new entered value is an empty string, then I don't want to accept the new value if I hit ESC then, the old value should remain.

    Read the article

  • Call a function when "event.GetFrom(m_cpVoice)==S_OK" (ergo when event happens) [SAPI 5.1 and C++]

    - by Jesuskiewicz
    Hello, I'm doing a project with a 3D model, that speaks. So, I'm using SAPI 5.1, and I want to call a function asynchronously when there's a Viseme event (in order to play the animation related to). How could I do it? Thank you very much. Note: I use : hRes = m_cpVoice-Speak(L"All I want is to solve this problem", SPF_ASYNC , NULL); And I know the CspEvent, event.eEventId . All I want is how to call a function when Sapi event happens

    Read the article

  • Help understanding .NET delegates, events, and eventhandlers

    - by Seth Spearman
    Hello, In the last couple of days I asked a couple of questions about delegates HERE and HERE. I confess...I don't really understand delegates. And I REALLY REALLY REALLY want to understand and master them. (I can define them--type safe function pointers--but since I have little experience with C type languages it is not really helpful.) Can anyone recommend some online resource(s) that will explain delegates in a way that presumes nothing? This is one of those moments where I suspect that VB actually handicaps me because it does some wiring for me behind the scenes. The ideal resource would just explain what delegates are, without reference to anything else like (events and eventhandlers), would show me how all everything is wired up, explain (as I just learned) that delegates are types and what makes them unique as a type (perhaps using a little ildasm magic)). That foundation would then expand to explain how delegates are related to events and eventhandlers which would need a pretty good explanation in there own right. Finally this resource could tie it all together using real examples and explain what wiring DOES happen automatically by the compiler, how to use them, etc. And, oh yeah, when you should and should not use delegates, in other words, downsides and alternatives to using delegates. What say ye? Can any of you point me to resource(s) that can help me begin my journey to mastery? EDIT One last thing. The ideal resource will explain how you can and cannot use delegates in an interface declaration. That is something that really tripped me up. Thanks for your help. Seth

    Read the article

  • C# Simple Event Handler for Setting Alarm

    - by yeeen
    Why does the following line "alarm.AlarmEvent += new AlarmEventHandler(alarm_Sound);" gives me "An object reference is required for the non-static field, method, or property 'AlarmClock.Alarm.alarm_Sound(object, System.EventArgs)'" public static void Main(string[] args) { Alarm alarm = new Alarm(new DateTime(2010, 4, 7, 23, 2, 0)); alarm.Set(); alarm.AlarmEvent += new AlarmEventHandler(alarm_Sound); } Full source code here: Program.cs AlarmEventArgs

    Read the article

  • jQuery and ASP.NET drop down problem

    - by Sayem Ahmed
    I have a drop down in an ASP.NET page. Whenever the value of the drop down changes an ASP.NET AJAX request is made to the server. I also attached a jQuery "change" event handler to that list to execute some code when the value is changed. So, probably two different event handlers are being attached to the same drop down, and it's causing some problems, i.e., sometimes wrong drop down values are sent to the server. I don't know why is this happening but I think attaching two different event handlers to a same drop down may be the reason. Can anyone tell me what is the problem here? If what I guessed is true, then is there any other way to execute some custom javascript code before asp.net AJAX request is sent ?

    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

  • CloseHandler<Window> and Window.ClosingHandler() working differently in IE

    - by stuff22
    It seems that CloseHandler and Window.ClosingHandler() are not working or are not triggering the events in the same way under IE as opposed to Firefox. Window.addWindowClosingHandler(new Window.ClosingHandler() { @Override public void onWindowClosing(ClosingEvent event) { event.setMessage(message); } Window.addCloseHandler(new CloseHandler<Window>() { @Override public void onClose(CloseEvent<Window> event) { //Window.alert("debug1"); if(recordId!=null){ DatabaseQueryServiceAsync dbQueryService = DatabaseQueryService.Util.getInstance(); dbQueryService.releaseRecordLock(recordId, new AsyncCallback<String>() { @Override public void onFailure(Throwable arg0) { } @Override public void onSuccess(String arg0) { } }); } } }); }); For example, the ClosingHandler under IE displays the message when I swap a panel within within my widget. This does not occur in Firefox. The CloseHandler doesn't seem to trigger at all when the window closes in IE, but does so in firefox. The interesting thing to point out there, is that when I put a Window.alert("debug1") message in the addCloseHandler() method it DOES run the callback below, but as soon as I remove it, the callback doesn't happen. In firefox it works and runs the callback in both situations. So, I'm basically pulling my hair out not really understanding what's going on. Any help would be greatly appreciated. Thanks.

    Read the article

  • Which event handler to use to record leaving page - onunload or onbeforeunload?

    - by symcbean
    Hi all, Having not any answers to my previous questions about using javascript to measure page turn times, I'm going to start writing my own code (!). To measure the length of tie it takes, I'm proposing dropping a cookie containing a timestamp when the user browses away from a page, then in a subsequent page, comparing that time with 'now' and sending back a request to a URL which will log the interval. It seems that there are 2 possible handlers I could associate the first block of code with - the onunload() handler or the onbeforeunload()? It's more important that it fail silently on browsers with no/broken support for the handler, than it be portable across every possible browser. Any pointers? Gotchas? TIA C.

    Read the article

  • Validate a XDocument against schema without the ValidationEventHandler (for use in a HTTP handler)

    - by Vaibhav Garg
    Hi everyone, (I am new to Schema validation) Regarding the following method, System.Xml.Schema.Extensions.Validate( ByVal source As System.Xml.Linq.XDocument, ByVal schemas As System.Xml.Schema.XmlSchemaSet, ByVal validationEventHandler As System.Xml.Schema.ValidationEventHandler, ByVal addSchemaInfo As Boolean) I am using it as follows inside a IHttpHandler - Try Dim xsd As XmlReader = XmlReader.Create(context.Server.MapPath("~/App_Data/MySchema.xsd")) Dim schemas As New XmlSchemaSet() : schemas.Add("myNameSpace", xsd) : xsd.Close() myXDoxumentOdj.Validate(schemas, Function(s As Object, e As ValidationEventArgs) SchemaError(s, e, context), True) Catch ex1 As Threading.ThreadAbortException 'manage schema error' Return Catch ex As Exception 'manage other errors' End Try The handler- Function SchemaError(ByVal s As Object, ByVal e As ValidationEventArgs, ByVal c As HttpContext) As Object If c Is Nothing Then c = HttpContext.Current If c IsNot Nothing Then HttpContext.Current.Response.Write(e.Message) HttpContext.Current.Response.End() End If Return New Object() End Function This is working fine for me at present but looks very weak. I do get errors when I feed it bad XML. But i want to implement it in a more elegant way. This looks like it would break for large XML etc. Is there some way to validate without the handler so that I get the document validated in one go and then deal with errors? To me it looks Async such that the call to Validate() would pass and some non deterministic time later the handler would get called with the result/errors. Is that right? Thanks and sorry for any goofy mistakes :).

    Read the article

  • VS/C#: Can I be notified of every event that gets handled while debugging?

    - by Daniel I-S
    I am currently troubleshooting a large and unwieldy GUI-based tool in Visual Studio, and was wondering whether there is any way to get some kind of notification (either by writing to the console or through a third-party tool) whenever any handled event occurs. This would make it a lot easier to track down what precisely is going on while I am interacting with this beast. Is there an 'on any event being handled' event I can handle, or some kind of add-in for VS which would make this possible?

    Read the article

  • Are there any shortcuts/easier(VB) style way for raising events in C#?

    - by Eric
    Example in VB I have a worker class Public Class worker Public Event EventNumber1(ByVal messages As Dictionary(Of Integer, String)) Public Event EventNumber2(ByVal message As String) Public Sub CallEventNumber1() Dim dict As New Dictionary(Of Integer, String) dict.Add(1, "EventNumber1 First message") dict.Add(2, "EventNumber1 Second message") RaiseEvent EventNumber1(dict) End Sub Public Sub CallEventNumber2() RaiseEvent EventNumber2("I am an EventNumber2 Message") End Sub End Class and wire them up in another class with AddHandler _worker.EventNumber1, AddressOf EventNumber1Handler AddHandler _worker.EventNumber2, AddressOf EventNumber2Handler and in C# the worker class class Worker { public delegate void EventNumber1Handler(Dictionary<int, string> messages); public delegate void EventNumber2Handler(string message); public event EventNumber1Handler EventNumber1; public event EventNumber2Handler EventNumber2; public void CallEventNumber1() { Dictionary<int, string> dict = new Dictionary<int, string>(); dict.Add(1, "EventNumber1 First message"); dict.Add(2, "EventNumber1 Second message"); if (EventNumber1 != null) EventNumber1(dict); } public void CallEventNumber2() { if (EventNumber2 != null) EventNumber2("I am an EventNumber2 Message"); } } and wire that up with worker.EventNumber1 += new Worker.EventNumber1Handler(worker_EventNumber1); worker.EventNumber2 += new Worker.EventNumber2Handler(worker_EventNumber2); So I guess my question is do I always need to add the delegate along with the event in c#? Is there any new syntax for c# 3.0/4.0? Regards _Eric

    Read the article

  • .NET Weak Event Handlers – Part II

    - by João Angelo
    On the first part of this article I showed two possible ways to create weak event handlers. One using reflection and the other using a delegate. For this performance analysis we will further differentiate between creating a delegate by providing the type of the listener at compile time (Explicit Delegate) vs creating the delegate with the type of the listener being only obtained at runtime (Implicit Delegate). As expected, the performance between reflection/delegate differ significantly. With the reflection based approach, creating a weak event handler is just storing a MethodInfo reference while with the delegate based approach there is the need to create the delegate which will be invoked later. So, at creating the weak event handler reflection clearly wins, but what about when the handler is invoked. No surprises there, performing a call through reflection every time a handler is invoked is costly. In conclusion, if you want good performance when creating handlers that only sporadically get triggered use reflection, otherwise use the delegate based approach. The explicit delegate approach always wins against the implicit delegate, but I find the syntax for the latter much more intuitive. // Implicit delegate - The listener type is inferred at runtime from the handler parameter public static EventHandler WrapInDelegateCall(EventHandler handler); public static EventHandler<TArgs> WrapInDelegateCall<TArgs>(EventHandler<TArgs> handler) where TArgs : EventArgs; // Explicite delegate - TListener is the type that defines the handler public static EventHandler WrapInDelegateCall<TListener>(EventHandler handler); public static EventHandler<TArgs> WrapInDelegateCall<TArgs, TListener>(EventHandler<TArgs> handler) where TArgs : EventArgs;

    Read the article

  • Why would a 'public event EventHandler cccc' be null?

    - by Matt
    Why would a 'public event EventHandler cccc' be null? I have a class that's public class Builder { public event EventHandler StartedWorking; public Builder() { // Constructor does some stuff } public void Start() { StartedWorking(this, eventargobject); //StartedWorking is null -- } } This seems straightforward and something I do all the time? Am I missing something obvious or is there something that could cause this? EDIT: Does this mean that if I fire an event that is not subscribed to in a client class I have to check that it is not null? EDIT-2: I guess I'd never had events that were never not subscribed to and hence never ran into this -- You learn something new every day Sorry about the seemingly stupid question....

    Read the article

  • ASP.NET CustomValidator trying to match to System.EventHandler?

    - by annakata
    I have markup so: <asp:TextBox runat="server" ID="Accountname" /> <asp:CustomValidator runat="server" ControlToValidate="Accountname" OnServerValidate="Accountname_CheckUnique" meta:resourcekey="ACCOUNTNAME_UNAVAILABLE" /> Codebehind so: protected void Accountname_CheckUnique(object source, ServerValidateEventArgs arguments) { arguments.IsValid = Foo(); } Which was working just fine, and then without changing anything on the page ASP now insists: No overload for 'Accountname_CheckUnique' matches delegate 'System.EventHandler' Well no, and nor should it according to MSDN. It's late and I'm tired, anybody know how to fix this or point out the glaring flaw in my comprehension?

    Read the article

  • ASP .NET Dynamically adding EventHandlers to button on Page_Load. EventHandler's do not fire the fir

    - by John
    Background: I am customizing an existing ASP .NET / C# application. It has it's own little "framework" and conventions for developers to follow when extending/customizing its functionality. I am currently extending some of it's administrative functionality, to which the framework provides a contract to enforce implementation of the GetAdministrationInterface() method, which returns System.Web.UI.Control. This method is called during the Page_Load() method of the page hosting the GUI interface. Problem: I have three buttons in my GUI, each of which have been assigned an Event Handler. My administration GUI loads up perfectly fine, but clicking any of the buttons doesn't do what I expect them to do. However, when I click them a second time, the buttons work. I placed breakpoints at the the beginning of each event handler method and stepped through my code. On the first click, none of the event handlers are triggered. On the second click, they are triggered. Any ideas? Example of Button Definition Button btn = new Button(); btn.Text = "Click Me Locked Screen"; bth.Click += new EventHandler(Btn_Click); Example of Event Handler Method Definition void Btn_Click(object sender, EventArgs e) { // Do Something }

    Read the article

  • Custom Event - invokation list implementation considerations

    - by M.A. Hanin
    I'm looking for some pointers on implementing Custom Events in VB.NET (Visual Studio 2008, .NET 3.5). I know that "regular" (non-custom) Events are actually Delegates, so I was thinking of using Delegates when implementing a Custom Event. On the other hand, Andrew Troelsen's "Pro VB 2008 and the .NET 3.5 Platform" book uses Collection types in all his Custom Events examples, and Microsoft's sample codes match that line of thought. So my question is: what considerations should I have when choosing one design over the other? What are the pros and cons for each design? Which of these resembles the inner-implementation of "regular" events? Below is a sample code demonstrating the two designs. Public Class SomeClass Private _SomeEventListeners As EventHandler Public Custom Event SomeEvent As EventHandler AddHandler(ByVal value As EventHandler) _SomeEventListeners = [Delegate].Combine(_SomeEventListeners, value) End AddHandler RemoveHandler(ByVal value As EventHandler) _SomeEventListeners = [Delegate].Remove(_SomeEventListeners, value) End RemoveHandler RaiseEvent(ByVal sender As Object, ByVal e As System.EventArgs) _SomeEventListeners.Invoke(sender, e) End RaiseEvent End Event Private _OtherEventListeners As New List(Of EventHandler) Public Custom Event OtherEvent As EventHandler AddHandler(ByVal value As EventHandler) _OtherEventListeners.Add(value) End AddHandler RemoveHandler(ByVal value As EventHandler) _OtherEventListeners.Remove(value) End RemoveHandler RaiseEvent(ByVal sender As Object, ByVal e As System.EventArgs) For Each handler In _OtherEventListeners handler(sender, e) Next End RaiseEvent End Event End Class

    Read the article

  • When and why does an EventHandler require objects to be final?

    - by Michiel Borkent
    I have the following code from a GWT Project that is part of the onModuleLoad() method (similar to Java's main method, if you don't know GWT): final TextBox t1 = new TextBox(); final Label lt1 = new Label(); t1.addKeyUpHandler(new KeyUpHandler() { @Override public void onKeyUp(KeyUpEvent event) { // TODO Auto-generated method stub if (!(t1.getText().matches("\\w{2}-\\w{2}-\\w{2}"))) lt1.setText("Invalid."); else lt1.setText("OK."); } }); Why do the two local variables have to be final here?

    Read the article

  • .NET EventHandlers - Generic or no?

    - by Chris Marasti-Georg
    Every time I start in deep in a C# project, I end up with lots of events that really just need to pass a single item. I stick with the EventHandler/EventArgs practice, but what I like to do is have something like: public delegate void EventHandler<T>(object src, EventArgs<T> args); public class EventArgs<T>: EventArgs { private T item; public EventArgs(T item) { this.item = item; } public T Item { get { return item; } } } Later, I can have my public event EventHandler<Foo> FooChanged; public event EventHandler<Bar> BarChanged; However, it seems that the standard for .NET is to create a new delegate and EventArgs subclass for each type of event. Is there something wrong with my generic approach? EDIT: The reason for this post is that I just re-created this in a new project, and wanted to make sure it was ok. Actually, I was re-creating it as I posted. I found that there is a generic EventHandler<TEventArgs, so you don't need to create the generic delegate, but you still need the generic EventArgs<T class, because TEventArgs: EventArgs. Another EDIT: One downside (to me) of the built-in solution is the extra verbosity: public event EventHandler<EventArgs<Foo>> FooChanged; vs. public event EventHandler<Foo> FooChanged; It can be a pain for clients to register for your events though, because the System namespace is imported by default, so they have to manually seek out your namespace, even with a fancy tool like Resharper... Anyone have any ideas pertaining to that?

    Read the article

  • Understanding AddHandler and pass delegates and events.

    - by Achilles
    I am using AddHandler to wire a function to a control's event that I dynamically create: Public Sub BuildControl(EventHandler as System.Delegate) dim objMyButton as new button AddHandler objMyButton.Click, EventHandler end Sub This code is generating a run-time exception stating: Unable to cast object of type 'MyEventHandlerDelegate' to type 'System.EventHandler' What am I not understanding about System.Delegate even though AddHandler takes as an argument of type "System.Delegate"? What Type does "EventHandler need to be to cast to a type that AddHandler can accept? Thanks for your help!

    Read the article

  • how do I get the index of a firing context menu item

    - by fishhead
    I would like to determine the index of the selected context menu item. But I don't want to build a unique eventhandler for each menu item...how do I do this MenuItem mi= StatusContextMenu.MenuItems.Add("Set option"); mi.MenuItems.Add(0,new MenuItem("Set to A", new EventHandler(SetLetter)) ); mi.MenuItems.Add(1,new MenuItem("Set to B", new EventHandler(SetLetter))); mi.MenuItems.Add(2,new MenuItem("Set to C ", new EventHandler(SetLetter))); mi.MenuItems.Add(3,new MenuItem("Set to D", new EventHandler(SetLetter))); private void SetLetter(object sender, System.EventArgs e) { index = ???? } C#, .net 2.0

    Read the article

  • C# - Removing event handlers - FormClosing event or Dispose() method

    - by Andy
    Suppose I have a form opened via the .ShowDialog() method. At some point I attach some event handlers to some controls on the form. e.g. // Attach radio button event handlers. this.rbLevel1.Click += new EventHandler(this.RadioButton_CheckedChanged); this.rbLevel2.Click += new EventHandler(this.RadioButton_CheckedChanged); this.rbLevel3.Click += new EventHandler(this.RadioButton_CheckedChanged); When the form closes, I need to remove these handlers, right? At present, I am doing this when the FormClosing event is fired. e.g. private void Foo_FormClosing(object sender, FormClosingEventArgs e) { // Detach radio button event handlers. this.rbLevel1.Click -= new EventHandler(this.RadioButton_CheckedChanged); this.rbLevel2.Click -= new EventHandler(this.RadioButton_CheckedChanged); this.rbLevel3.Click -= new EventHandler(this.RadioButton_CheckedChanged); } However, I have seen some examples where handlers are removed in the Dispose() method. Is there a 'best-practice' way of doing this? (Using C#, Winforms, .NET 2.0) Thanks.

    Read the article

  • Is there a better way to write this repetitive event-declaration code in C# when implementing an int

    - by Damien Wildfire
    I have a lot of code like the following, where I explicitly implement some events required by an interface. public class IMicrowaveNotifier { event EventHandler<EventArgs> DoorClosed; event EventHandler<EventArgs> LightbulbOn; // ... } public class Microwave : IMicrowaveNotifier { private EventHandler<EventArgs> _doorClosed; event EventHandler<EventArgs> IMicrowaveNotifier.DoorClosed { add { lock (this) _doorClosed += value; } remove { lock (this) _doorClosed -= value; } } private EventHandler<EventArgs> _lightbulbOn; event EventHandler<EventArgs> IMicrowaveNotifier.LightbulbOn { add { lock (this) _lightbulbOn += value; } remove { lock (this) _lightbulbOn -= value; } } // ... } You can see that much of this is boilerplate. In Ruby I'd be able to do something like this: class Microwave has_events :door_closed, :lightbulb_on, ... end Is there a similar shorter way of removing this boilerplate in C#? Update: I left a very important part out of my example: namely, the events getting implemented are part of an interface, and I want to implement it explicitly. Sorry for not mentioning this earlier!

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >