Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
T
TopJS3API
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Carver_Hu
TopJS3API
Commits
0b57cfae
Commit
0b57cfae
authored
Jan 17, 2020
by
Carver_Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
简易计算界面
parent
8417f2bc
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
99 additions
and
0 deletions
+99
-0
calc.js
简易计算界面/calc.js
+99
-0
No files found.
简易计算界面/calc.js
0 → 100644
View file @
0b57cfae
var
widget
=
{
name
:
'outer'
,
type
:
'FormGridLayout'
,
title
:
'calc'
,
property
:
{
enabled
:
true
},
child
:
[
{
name
:
'inner1'
,
type
:
'FormGridLayout'
,
property
:
{
enabled
:
true
,
columns
:
3
},
child
:[
{
name
:
'line1'
,
type
:
'LineEdit'
,
title
:
'参数1:'
,
property
:
{
enabled
:
true
},
},
{
name
:
'combobox'
,
type
:
'ComboBox'
,
title
:
'运算符:'
,
property
:
{
enabled
:
true
,
item_list
:[
'+'
,
'-'
,
'*'
,
'/'
],
},
},
{
name
:
'line2'
,
type
:
'LineEdit'
,
title
:
'参数2:'
,
property
:
{
enabled
:
true
},
},
]
},
{
name
:
'inner2'
,
type
:
'FormGridLayout'
,
property
:
{
enabled
:
true
,
columns
:
2
},
child
:[
{
name
:
'button'
,
type
:
'ToolButton'
,
property
:
{
enabled
:
true
,
text
:
'执行计算'
},
callback
:
function
(){
var
line1Value
=
this
.
getObject
(
'line1'
).
getData
();
var
line2Value
=
this
.
getObject
(
'line2'
).
getData
();
var
combobox
=
this
.
getObject
(
'combobox'
).
getData
();
var
reg
=
/^
[
0-9
]
+.
?[
0-9
]
*$/
;
if
(
line1Value
==
''
||
line2Value
==
''
){
GUI
.
msgbox
({
text
:
'参数不能为空!'
});
}
else
if
(
combobox
==
''
){
GUI
.
msgbox
({
text
:
'运算符不能为空!'
});
}
else
if
(
reg
.
test
(
line1Value
)
==
false
||
reg
.
test
(
line2Value
)
==
false
){
GUI
.
msgbox
({
text
:
'参数只能是数字!'
});
}
else
{
var
param1
=
Number
(
line1Value
);
var
param2
=
Number
(
line2Value
);
switch
(
combobox
){
case
'+'
:
var
result
=
param1
+
param2
;
break
;
case
'-'
:
var
result
=
param1
-
param2
;
break
;
case
'*'
:
var
result
=
param1
*
param2
;
break
;
case
'/'
:
var
result
=
param1
/
param2
;
break
;
};
this
.
getObject
(
'label'
).
setData
(
'value'
,
String
(
result
));
}
}
},
{
name
:
'label'
,
type
:
'LineEdit'
,
property
:
{
enabled
:
true
,
alignment
:
'left'
},
}
]
}
],
};
var
ret
=
GUI
.
showForm
({
'title'
:
'计算器'
,
'use_core_engine'
:
true
,
'items'
:
widget
,
'size'
:
'500*500'
,
})
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment