Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DateCalculator: Make the enter key trigger calculation #632

Conversation

stevenyoungs
Copy link
Contributor

Pressing the enter or keypad-enter keys in either of the two entry widgets now acts the same as clicking the Calculate button.

Typically your hand will be on the keyboard to enter the second date value. Pressing enter can be a quicker and more convenient way to trigger calculation than existing methods:

  1. moving your hand back to the mouse, moving the mouse over the Calculate button and clicking it.
  2. pressing tab twice to move the input focus to the Calculate button and press enter
    Both these methods continue to work

Pressing the enter of keypad enter keys in either of the two entry
widgets now acts the same as clicking the Calculate button.
@GaryGriffin GaryGriffin merged commit 4ca35ed into gramps-project:maintenance/gramps52 Jan 17, 2025
@emyoulation
Copy link
Contributor

emyoulation commented Jan 22, 2025

I did a few tests calculations.

For some reason it is only showing Years and Months in results, but not Days, for some calculations. seems to be for date +/- date calculations. e.g. 22 Jan 2025 -13 Jul 1980
y,m,d offset calculations showed the day.

image|50%

Noted that the Height for the detached gramplet in the .gpr.py needs to be increased to show the buttons. I increased it to 300.

The width is too narrow for the default "Enter an expression in the entries above and click Calculate." text in the Result text box. Perhaps that field could be 2 rows in height with text wrapping? (Increasing the number of rows would necessitate increasing the detached height.)

Note that Expression1 and Expression2 were the previous label. So "expression" may no longer be intuitive. Plus... 2 values have to be entered, so a singular form is incorrect. Perhaps it could be "Enter date values in the text boxes above and click Calculate."

@stevenyoungs
Copy link
Contributor Author

@emyoulation Thanks for the feedback!

For some reason it is only showing Years and Months in results, but not Days, for some calculations. seems to be for date +/- date calculations. e.g. 22 Jan 2025 -13 Jul 1980

I've looked into this one. The result of subtracting the two dates in gramps is a span (class Span). The default precision of a Span, used when converting it to a string, is 2. This means "only most two significant levels (year, month, day)". This explains the result you see.
The Span class defaults the precision to 2 and it's a hard coded value. You can however specify the precision when converting the Span to a string. I'll create a separate PR to change this to 3 for DateCalculator.

@stevenyoungs stevenyoungs deleted the datecalculator-enter branch January 23, 2025 19:55
@stevenyoungs
Copy link
Contributor Author

The other points are covered in #636

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants