< Back to Snippets

Add in Place

Replace the standard + button with a + button that will treat the selected line in your stack as the top of the stack. So, selected line is replaced with sum of selected line and the line above it. Works exactly like normal + if nothing is selected. It should be pretty obvious from this snippet how to replicate for −, ×, and ÷


<root>
  ...
  <layout>
    ...
    <button label="+" action="AddInPlace" longPressAction="MathSquare.Action" style="OperatorButtonStyle"/>
    ...
  </layout>
  ...
  <values>
    ...
    <subroutine ID="AddInPlace">
      <StackBox.RollToTop/>
      <MathAdd.Action/>
      <StackBox.RollToTopUndo/>
    </subroutine>
    ...
  </values>
</root>