locked
Consuming events in javascript RRS feed

  • Question

  • Hi,

    I am using javascript to write a metro style application. It has a winRT component written in C++. The component provides a event whose signature is:

    public delegate void EventHandler(Platform::String^ path, Windows::Foundation::Collections::IMap<String^, Windows::Foundation::PropertyValue^> ^userData);

    How can I consume this event in javascript?

    I tried the following code:

    var jseventHandler = function (arg1) {};

    nativeObject.onsomeevent = jseventHandler;

    and also:

    var jseventHandler = function (arg1, arg2) {};

    nativeObject.onsomeevent = jseventHandler;

    But, either way it does not work and I get the following error:

    0x800a13e3 - JavaScript runtime error: The function 'jseventHandler' has an invalid signature and cannot be called.

    Please Help.


    Friday, June 22, 2012 12:18 PM

All replies

  • Hi Nick,

    This documentation covers handling events in Javascript from a Native component:

    http://msdn.microsoft.com/en-us/library/windows/apps/hh441569(v=vs.110).aspx

    Jeff


    Jeff Sanders (MSFT)

    Friday, June 22, 2012 3:50 PM
    Moderator
  • Hi Jeff,

    Thanks fir replying. I have already gone through that link several times but it does not help. It only describes an event handler for a particular case.

    In my case, the delgate has a map which takes PropertyValue as its value type. If I change it to "String", then everything works fine. Therefore, I doubt it does not work in the [particular case where the value type is PropertyValue in IMap, may be because Javascript is not able to instantiate such kind of maps when called through events. It might be a bug in VS 2012 or WinRT.

    Please help.

    Thanks in advance.

    Saturday, June 23, 2012 8:33 AM