Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sciter wj008 #324

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ Check [this page](http://sciter.com/developers/sciter-sdk-bindings/) for other l

----

If you want to use this source

go.mod
```
module yourxxx

require github.com/sciter-sdk/go-sciter latest

replace github.com/sciter-sdk/go-sciter latest => github.com/wj008/go-sciter latest
```

# Attention

Expand Down
6 changes: 3 additions & 3 deletions callbacks.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

// typedef BOOL SC_CALLBACK SciterElementCallback(HELEMENT he, LPVOID param);

BOOL SC_CALLBACK SciterElementCallback_cgo(HELEMENT he, LPVOID param)
SBOOL SC_CALLBACK SciterElementCallback_cgo(HELEMENT he, LPVOID param)
{
return goSciterElementCallback(he, param);
}
Expand All @@ -27,7 +27,7 @@ VOID SC_CALLBACK LPCSTR_RECEIVER_cgo(LPCSTR str, UINT str_length, LPVOID param)
}

// typedef BOOL SC_CALLBACK ElementEventProc(LPVOID tag, HELEMENT he, UINT evtg, LPVOID prms);
BOOL SC_CALLBACK ElementEventProc_cgo(LPVOID tag, HELEMENT he, UINT evtg, LPVOID prms)
SBOOL SC_CALLBACK ElementEventProc_cgo(LPVOID tag, HELEMENT he, UINT evtg, LPVOID prms)
{
return goElementEventProc(tag, he, evtg, prms);
}
Expand Down Expand Up @@ -59,7 +59,7 @@ INT SC_CALLBACK ELEMENT_COMPARATOR_cgo(HELEMENT he1, HELEMENT he2, LPVOID param)

// typedef BOOL SC_CALLBACK KeyValueCallback(LPVOID param, const VALUE* pkey, const VALUE* pval);

BOOL SC_CALLBACK KeyValueCallback_cgo(LPVOID param, const VALUE* pkey, const VALUE* pval)
SBOOL SC_CALLBACK KeyValueCallback_cgo(LPVOID param, const VALUE* pkey, const VALUE* pval)
{
return goKeyValueCallback(param, (VALUE*)pkey, (VALUE*)pval);
}
20 changes: 10 additions & 10 deletions examples/callback/index.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<div>
<button id="btn">Click Me</button>
</div>
<script type="text/tiscript">
function callback(abc){
view.msgbox(#information,abc);
}

$(#btn).on("click",function(){
var obj = {num:100, str:"Hello World"};
view.getNetInformation(1,"test",callback, obj);
});
</script>
<script type="text/javascript">
function callback(abc){
console.log(abc);
}
document.on('click','#btn',function (ev){
var obj = {num:100, str:"Hello World"};
var view=Window.this;
view.xcall('getNetInformation',1,"test",callback, obj);
})
</script>
5 changes: 5 additions & 0 deletions examples/resx/html/css/main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
html {
width: 300px; /* preferred/initial width */
height: 240px; /* content will not overflow, no vertical scrollbars on the window */
background-color: #E5B783;
}
Binary file added examples/resx/html/icon/i32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 36 additions & 0 deletions examples/resx/html/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<html lang="zh-cn" window-resizable="false" window-icon="resx://html/icon/i32.png">

<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<link rel="stylesheet" href="resx://html/css/main.css">
<script src="resx://html/js/zepto.js"></script>
<script src="resx://html/js/util.js"></script>
</head>
<body>
<div class="main">
<div>
<button id="btn1">btn1</button>
<button id="btn2">btn2</button>
</div>
<div style="margin-top: 30px;">
<textarea id="out"></textarea>
</div>
</div>
</body>

<script>
//Center the current window
util.moveCenter(800, 500);
util.ready(function (view) {
$('#btn1').on('click', function () {
$('#out').val("click-> btn1")
});
$('#btn2').on('click', function () {
$('#out').val("click-> btn1")
});
})
</script>

</html>
52 changes: 52 additions & 0 deletions examples/resx/html/js/util.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
window.util = {};

//open a dialog
util.openDialog = function (url, width = 800, height = 600, data = null) {
return Window.this.modal({
url: url,
parent: Window.this,
type: Window.FRAME_WINDOW,
width: width,
height: height,
alignment: -8,
parameters: data
});
}

//random
util.randomString = function (len) {
len = len || 32;
let chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678';
let maxPos = chars.length;
let pwd = '';
for (let i = 0; i < len; i++) {
pwd += chars.charAt(Math.floor(Math.random() * maxPos));
}
return pwd;
}

//Center the current window
util.moveCenter = function (width = 0, height = 0) {
let view = Window.this;
let [width1, height1] = view.box('dimension', 'border');
let [width2, height2] = view.box('dimension', 'client');
if (width == 0) {
width = width2;
}
if (height == 0) {
height = height2;
}
let nw = width + (width1 - width2);
let nh = height + (height1 - height2);
let [sw, sh] = view.screenBox('frame', 'dimension');
let left = (sw - nw) / 2;
let top = (sh - nh) / 2;
view.move(left, top, width, height, "client");
}
//wait ready
util.ready = function (fn) {
let timer = setInterval(function () {
clearInterval(timer)
fn(Window.this)
}, 10)
}
Loading