Awesomium C no response from awe_webview_set_callback_js_callback

I asked this question in Awesomium forms but haven't received an answer yet and figured I could speed things up by asking here.

I cannot reach any breakpoint in my callback_UI () when I click the corresponding html button. The links work fine to navigate between pages, but the callback doesn't fire.

Here is my simple C code:

#define BUFFER_LEN_CALLBACKS 100
#define NAME_UIOBJ_INDEX "object_index"
#define NAME_UICALL_INDEX "callback_index"

void callback_UI(awe_webview* view, awe_string const* object_name, awe_string const* callback_name, awe_jsarray const* args){

        char buff_object_name[BUFFER_LEN_CALLBACKS] = {0};
        char buff_callback_name[BUFFER_LEN_CALLBACKS] = {0};
        //char buff_args[BUFFER_LEN_CALLBACKS] = {0};

        // Get the strings.
        awe_string_to_utf8(object_name, buff_object_name, BUFFER_LEN_CALLBACKS);
        awe_string_to_utf8(callback_name, buff_callback_name, BUFFER_LEN_CALLBACKS);

        string s_obj_name(buff_object_name);
        string s_call_name(buff_callback_name);

        HandleCallback( s_obj_name, s_obj_name );
}

void create_uiobject(awe_webview* view, char* name){
    awe_string* awes_name = awe_string_create_from_ascii(name, sizeof(name));
    awe_webview_create_object(view, awes_name);
    awe_string_destroy(awes_name);
}

void create_uicallback(awe_webview* view,  char* name, char* callback){
    awe_string* awes_name = awe_string_create_from_ascii(name, sizeof(name));
    awe_string* awes_callback = awe_string_create_from_ascii(
        callback,sizeof(callback));
    awe_webview_set_object_callback(view, awes_name, awes_callback);
    awe_string_destroy(awes_name);
    awe_string_destroy(awes_callback);

    // Set our UI callback to let the javascript talk to our program.
    awe_webview_set_callback_js_callback(view, callback_UI);
}

void setup_javascript_objects(awe_webview* view){
    // Create our object names.
    create_uiobject(view,NAME_UIOBJ_INDEX);

    // Create our object callbacks.
    create_uicallback(view, NAME_UIOBJ_INDEX, NAME_UICALL_INDEX);
}

      

And here is my html side javascript code:

<input type="button" value="Click Me!"onclick="object_index.callback_index('hello!')" />

      

Everything else works great. awe_webview_set_callback_js_console_message () tells me that "object_index" is undefined. I am using awe_webview_create_object () for this, but perhaps I am using it incorrectly. Idk.

Does anyone have any ideas?

+3


source to share


1 answer


The problem was my calls:

awe_string_create_from_ascii(name, sizeof(name));

      

should be:



awe_string_create_from_ascii(name, strlen(name));

      

It was a subtle but devastating mistake. I hope this post can help others who find themselves in a similar situation.

0


source