Opened 14 years ago

Closed 14 years ago

#1903 closed defect (fixed)

OLPC-Calculate Activity – Cannot enter negative values to the entry box.

Reported by: Niranjala80 Owned by: rwh
Priority: Normal Milestone: Unspecified
Component: Calculate Version: Unspecified
Severity: Minor Keywords:
Cc: Distribution/OS: Unspecified
Bug Status: New

Description

Description:

Press (-) to begin a new number entry after a previous calculation was done.

For instance,
User enters the following to the entry box.
1+2
The answer, User got is:
3
Click on the entry box.
Press negative (-) sign.
It displayed as 3- on the entry box.

The entry box should display the negative sign.

Steps to recreate the defect:
Precondition
User should be in the Calculator Activity

  1. Power on OLPC
  2. Click on the calculate icon on home page.
  3. Enter whatever calculation to the entry box.
  4. Click on Entry button.
  5. Get the result on the right side box.
  6. Click on entry box
  7. Press negative sign (-).
  8. Verify the displayed value on the entry box.

Actual Result:
Cannot enter negative values to the entry box and user enters, it is displaying the value as follows in the entry box. (Previous calculation result used.)
Eg: 3-

Expected Result:
Entry of negative number should be allowed and it should display properly in the entry box.

Tested Environment:
OS Build: OS 13
Machine Type: XO 1.0
Firmware: Q2E42
Security Disable: Yes
Sugar Version: 0.84.14
Activity Version: 30

Change History (3)

comment:1 Changed 14 years ago by quozl

Reproduced on XO-1.5 using same activity version.

Diagnosis:

The minus key used for entering the negative sign is also a mathematical operator key, and the meaning is thus overloaded. In astparser.py the character "-" is in both the DIADIC_OPS and PRE_OPS.

In calculate.py, when characters typed are being processed, which is in function button_pressed where type is set to TYPE_TEXT, the following code appears:

if tlen == 0 and (str in self.parser.get_diadic_operators() \
    or str in self.parser.get_post_operators()) and \
    self.parser.get_var('Ans') is not None: # and \
# logic better?     (str not in self.parser.get_pre_operators() or str == '+'):
    ans = self.format_insert_ans()
    self.text_entry.set_text(ans + str)
    self.text_entry.set_position(len(ans) + len(str))
    self.ans_inserted = True

The check of PRE_OPS is commented out. This may relate.

comment:2 Changed 14 years ago by garycmartin

  • Distribution/OS changed from Other (name your distribution in the description) to Unspecified
  • Keywords OS13 removed
  • Version changed from 0.84.x to Unspecified

I believe this is a feature (tested in Calculate-30). You can type a sequence of equations picking up the previous result. Any operator can be used, though I agree that the - operator is one you might more commonly use and not want this behaviour (user is forced to type something 0-3 if they actually want -3 as the first number in an equation). Probably only solution is to loose this feature as clicking an answer already inserts it into the equation for similar functionality.

comment:3 Changed 14 years ago by garycmartin

  • Resolution set to fixed
  • Status changed from new to closed

Reinier committed a patch in git, should be in Calculate-32 once released. The minus symbol no longer pulls in the previous answer (however other operators like *+/ still do). Seems a bit of s sneaky patch, but it does at least resolve this specific use case.

Note: See TracTickets for help on using tickets.