Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
110 lines (89 loc) · 2.58 KB

File metadata and controls

110 lines (89 loc) · 2.58 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
//
// STWebView.cpp
// SheepTower
//
// Created by Li xuechuan on 13-7-17.
//
//
#include "STWebView.h"
#include "STWebViewImpl.h"
USING_NS_CC;
NS_CC_EXT_BEGIN
STWebView::STWebView(void)
: m_webViewImpl(NULL)
{
}
STWebView::~STWebView()
{
if (m_webViewImpl){
delete m_webViewImpl;
m_webViewImpl = NULL;
}
unregisterScriptWebViewHandler();
// [m_webView release];
// m_webView = NULL;
}
bool STWebView::loadURL(const char *url , CCRect rect){
if(!m_webViewImpl){
m_webViewImpl = __createWebView(this);
}
return m_webViewImpl->loadURL(url, rect);
// if(!m_webView){
// m_webView = [[STWebViewIOS alloc] init];
// }
// return [m_webView loadURL:url frame:CGRectMake(rect.origin.x, rect.origin.y, rect.size.width, rect.size.height)];
}
bool STWebView::init()
{
m_nScriptWebViewHandler = 0;
return true;
}
STWebView *STWebView::create(){
STWebView *webView = new STWebView();
if (webView && webView->init())
{
webView->autorelease();
return webView;
}
CC_SAFE_DELETE(webView);
return NULL;
}
void STWebView::removeFromSuperview(){
if (m_webViewImpl){
delete m_webViewImpl;
m_webViewImpl = NULL;
}
}
void STWebView::registerScriptWebViewHandler(int handler){
unregisterScriptWebViewHandler();
m_nScriptWebViewHandler = handler;
}
/**
* Unregisters a script function that will be called for EditBox events.
*/
void STWebView::unregisterScriptWebViewHandler(void){
if(0 != m_nScriptWebViewHandler )
{
CCScriptEngineManager::sharedManager()->getScriptEngine()->removeScriptHandler(m_nScriptWebViewHandler);
m_nScriptWebViewHandler = 0;
}
}
void STWebView::handleScriptEventHandler(const char *str){
CCLog("---handleScriptEventHandler %s \n",str);
if (NULL != str && 0 != m_nScriptWebViewHandler)
{
cocos2d::CCScriptEngineProtocol* pEngine = cocos2d::CCScriptEngineManager::sharedManager()->getScriptEngine();
//pEngine->executeEvent(m_nScriptWebViewHandler, str,this);
// CCLuaValueDict dict;
// dict["name"] = CCLuaValue::stringValue("failed");
// dict["request"] = CCLuaValue::ccobjectValue(this, "CCHTTPRequest");
//
//TO.DO after 2.1.4 use CCScriptEngineProtocol
CCLuaStack* stack = CCLuaEngine::defaultEngine()->getLuaStack();
stack->clean();
//stack->pushCCLuaValueDict(dict);
stack->pushString(str);
stack->executeFunctionByHandler(m_nScriptWebViewHandler, 1);
}
}
NS_CC_EXT_END
Morty Proxy This is a proxified and sanitized view of the page, visit original site.