forked from livecode/livecode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathem-dialog.js
More file actions
83 lines (65 loc) · 3.21 KB
/
Copy pathem-dialog.js
File metadata and controls
83 lines (65 loc) · 3.21 KB
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
/* -*-Javascript-*-
Copyright (C) 2015 Runtime Revolution Ltd.
This file is part of LiveCode.
LiveCode is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License v3 as published by the Free
Software Foundation.
LiveCode is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
mergeInto(LibraryManager.library, {
$LiveCodeDialog__deps: ['$LiveCodeUtil'],
$LiveCodeDialog: {
showAlert: function(message_buffer, message_length) {
var message = LiveCodeUtil.stringFromUTF16(message_buffer, message_length);
alert(message);
return 0;
},
showConfirm: function(message_buffer, message_length) {
var message = LiveCodeUtil.stringFromUTF16(message_buffer, message_length);
// Confirm returns true/false but we need the button ID
var result = confirm(message);
if (result) {
return 0;
} else {
return 1;
}
},
showPrompt: function(message_buffer, message_length, default_buffer, default_length, return_buffer, return_length) {
var message = LiveCodeUtil.stringFromUTF16(message_buffer, message_length);
var default_value = LiveCodeUtil.stringFromUTF16(default_buffer, default_length);
// Prompt the user for some text input. If cancelled, will return null.
var result = prompt(message, default_value);
if (result === null) {
return false;
}
// Allocate a buffer and store encode the string into it
var buffer = LiveCodeUtil.stringToUTF16(result);
var buffer_length = result.length*2;
{{{ makeSetValue('return_buffer', '0', 'buffer', 'i32') }}};
{{{ makeSetValue('return_length', '0', 'buffer_length', 'i32') }}};
return true;
}
},
MCEmscriptenDialogShowAlert__deps: ['$LiveCodeDialog'],
MCEmscriptenDialogShowAlert: function(message, message_length) {
return LiveCodeDialog.showAlert(message, message_length);
},
MCEmscriptenDialogShowConfirm__deps: ['$LiveCodeDialog'],
MCEmscriptenDialogShowConfirm: function(message, message_length) {
return LiveCodeDialog.showConfirm(message, message_length);
},
MCEmscriptenDialogShowPrompt__deps: ['$LiveCodeDialog'],
MCEmscriptenDialogShowPrompt: function(message_buffer, message_length, default_buffer, default_length, return_buffer, return_length) {
return LiveCodeDialog.showPrompt(message_buffer, message_length, default_buffer, default_length, return_buffer, return_length);
},
});
/*
* Local Variables:
* tab-width: 4
* indent-tabs-mode: t
* End:
*/