3
我在Awesomium表單上問過這個問題,但我還沒有收到任何迴應,並且我想我也可以通過在這裏詢問來加快速度。Awesomium C沒有迴應awe_webview_set_callback_js_callback
當我按下相應的html按鈕時,我無法在我的callback_UI()內達到任何斷點。鏈接可以在頁面之間傳遞,但回調不會被觸發。
這裏是我的簡單的C端代碼:
#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);
}
這裏是我的html端JavaScript代碼:
<input type="button" value="Click Me!"onclick="object_index.callback_index('hello!')" />
其他一切工作正常。 awe_webview_set_callback_js_console_message()告訴我「object_index」沒有被定義。我使用awe_webview_create_object()來做到這一點,但也許我錯了。 IDK。
有沒有人有任何想法?