Samples
Samples
Calculator.OSX
Language: Silver, Platform: All, Category: Calculator
https://github.com/remobjects/ElementsSamples/tree/master/Silver/All/Calculator/Calculator.OSX
-
Calculator.OSX
-
References
- Cocoa
- libElements
- rtl
- libToffee
- libSwift
- Source Files
- Other Files
-
References
MainWindowController.swift
import AppKit
@IBObject public class MainWindowController : NSWindowController {
@IBOutlet weak var edValue: NSTextField!
init() {
super.init(windowNibName: "MainWindowController");
// Custom initialization
}
public override func windowDidLoad() {
super.windowDidLoad();
// Implement this method to handle any initialization after your window controller's
// window has been loaded from its nib file.
}
@IBAction
public func pressBackButton(_ sender: id!) {
var s = edValue.stringValue
if s.length > 0 {
s = s.substringToIndex(s.length - 1)
edValue.stringValue = s
}
}
@IBAction
public func pressExitButton(_ sender: id!) {
close()
}
@IBAction
public func pressEvaluateButton(_ sender: id!) {
__try {
var eval = Evaluator()
edValue.stringValue = "" + eval.Evaluate(edValue.stringValue)
} __catch e: EvaluatorError {
var alert = NSAlert()
alert.messageText = "Error evaluating: " + e.reason
alert.runModal()
}
}
@IBAction
public func pressCharButton(_ sender: id!) {
edValue.stringValue += (sender as! NSButton).title
}
}
