From: Romain Chanoir Date: Mon, 13 Jan 2014 12:00:14 +0000 (-0500) Subject: examples: adds a 'C' button to the calculator X-Git-Tag: v0.6.4~32^2~15 X-Git-Url: http://nitlanguage.org examples: adds a 'C' button to the calculator Signed-off-by: Romain Chanoir --- diff --git a/examples/calculator.nit b/examples/calculator.nit index d1417ad..107be09 100644 --- a/examples/calculator.nit +++ b/examples/calculator.nit @@ -27,7 +27,12 @@ class CalculatorContext fun push_op( op : Char ) do apply_last_op_if_any - last_op = op # store for next push_op + if op == 'C' then + self.result = 0.0 + last_op = null + else + last_op = op # store for next push_op + end # prepare next current after_point = null @@ -175,6 +180,12 @@ class CalculatorGui but_dot.signal_connect( "clicked", self, '.' ) container.attach( but_dot, 1, 4, 1, 1 ) + #C + var but_c = new GtkButton.with_label( "C" ) + but_c.request_size( 64, 64 ) + but_c.signal_connect("clicked", self, 'C') + container.attach( but_c, 2, 4, 1, 1 ) + win.show_all end end