diff --git a/exp_scenario/module/gui/calculator.lua b/exp_scenario/module/gui/calculator.lua index 772f82cd..be7373c2 100644 --- a/exp_scenario/module/gui/calculator.lua +++ b/exp_scenario/module/gui/calculator.lua @@ -83,13 +83,13 @@ Elements.calculator_input_textfield = Gui.define("calculator/input_textfield") width = 400, } ---- Output label -Elements.calculator_result_label = Gui.define("calculator/result_label") +--- Output text box +Elements.calculator_result_text_box = Gui.define("calculator/result_text_box") :draw{ - type = "label", - caption = "", - name = "calculator_result_label", - style = "heading_2_label", + type = "text-box", + text = "", + read_only = true, + name = "calculator_result_text_box", } --- Container added to the screen @@ -98,7 +98,7 @@ Elements.container = Gui.define("calculator/container") local screen_frame = Gui.elements.screen_frame(parent, nil, true) local header = Gui.elements.header(screen_frame, { caption = { "exp-gui_calculator.tooltip" } }) Elements.calculator_input_textfield(screen_frame) - Elements.calculator_result_label(screen_frame) + Elements.calculator_result_text_box(screen_frame) Elements.calculator_info_label(screen_frame) return Gui.elements.screen_frame.get_root_element(screen_frame) end) @@ -327,16 +327,16 @@ end --- Value change function Elements.change(event) - local label = event.element.parent.calculator_result_label + local label = event.element.parent.calculator_result_text_box if event.text == "" then - label.caption = "" + label.text = "" return end local ok, result = Elements.parse(event.text:lower()) label.style.font_color = ok and {1, 1, 1} or {1, 0, 0} - label.caption = ok + label.text = ok and ("= " .. format_number(result, false)) or (type(result) == "table" and result or {"", {"exp-gui_calculator.error"}, tostring(result)}) end diff --git a/exp_scenario/module/locale/en.cfg b/exp_scenario/module/locale/en.cfg index 56c9c4d0..0a960a28 100644 --- a/exp_scenario/module/locale/en.cfg +++ b/exp_scenario/module/locale/en.cfg @@ -271,7 +271,7 @@ inserted=Inserted __1__ __2__ into __3__ [exp-gui_calculator] tooltip=Calculator -caption=Supported Operators: + - * / % () ^ ** !\nPrefix: K M G T P\nBase: 0x 0b 0o\nFunction: ABS, CEIL, EXP, FLOOR, LN, LOG, ROUND, SQRT, TRUNC +caption=Operator\n+ - * / % () ^ ** !\nPrefix\nK M G T P\nBase\n0x 0b 0o\nFunction\nABS, CEIL, EXP, FLOOR, LN, LOG, ROUND, SQRT, TRUNC error=[ERROR] input_too_long=Input too long factorial_neg=Factorial of a negative number __1__ diff --git a/exp_scenario/module/locale/zh-CN.cfg b/exp_scenario/module/locale/zh-CN.cfg index b23757d0..717c13ef 100644 --- a/exp_scenario/module/locale/zh-CN.cfg +++ b/exp_scenario/module/locale/zh-CN.cfg @@ -273,7 +273,7 @@ inserted=自動填入 __1__ __2__ 到 __3__ [exp-gui_calculator] tooltip=計算機 -caption=支援的運算符: + - * / % () ^ ** !\n詞頭: K M G T P\n進制: 0x 0b 0o\n函數: ABS, CEIL, EXP, FLOOR, LN, LOG, ROUND, SQRT, TRUNC +caption=運算符\n+ - * / % () ^ ** !\n詞頭\nK M G T P\n進制\n0x 0b 0o\n函數\nABS, CEIL, EXP, FLOOR, LN, LOG, ROUND, SQRT, TRUNC error=[錯誤] input_too_long=輸入太長 factorial_neg=負數的階乘 __1__ diff --git a/exp_scenario/module/locale/zh-TW.cfg b/exp_scenario/module/locale/zh-TW.cfg index b23757d0..717c13ef 100644 --- a/exp_scenario/module/locale/zh-TW.cfg +++ b/exp_scenario/module/locale/zh-TW.cfg @@ -273,7 +273,7 @@ inserted=自動填入 __1__ __2__ 到 __3__ [exp-gui_calculator] tooltip=計算機 -caption=支援的運算符: + - * / % () ^ ** !\n詞頭: K M G T P\n進制: 0x 0b 0o\n函數: ABS, CEIL, EXP, FLOOR, LN, LOG, ROUND, SQRT, TRUNC +caption=運算符\n+ - * / % () ^ ** !\n詞頭\nK M G T P\n進制\n0x 0b 0o\n函數\nABS, CEIL, EXP, FLOOR, LN, LOG, ROUND, SQRT, TRUNC error=[錯誤] input_too_long=輸入太長 factorial_neg=負數的階乘 __1__