-
-
Notifications
You must be signed in to change notification settings - Fork 418
Add right click popup for keyboard buttons #10220
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clang-Tidy found issue(s) with the introduced code (1/1)
|
Hi @jrcleeman , please fix code style issues and also clang-tidy problems. |
|
Hi @jrcleeman , I do not think that the proposed solution is flexible and actually it relies on special conditions. I suggest to add a separate field in |
ihhub
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @jrcleeman , this version is way better than the original one. We are definitely on the right track. I left a few more comments here. Would you mind to take a look at them?
| // This is used only for buttons which should have pressed state for some layouts. | ||
| bool isInvertedRenderingLogic{ false }; | ||
|
|
||
| std::string helpTitle; // e.g., "Space", "Backspace", "Shift" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please put newly added comments before member declaration as it's done above.
|
|
||
| const size_t letterRows = buttonLetters.size(); | ||
|
|
||
| for ( size_t row = 0; row < buttons.size(); ++row ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use ranged loops here to avoid indexing arrays.
| fheroes2::showStandardTextMessage( title, _( "Insert this character." ), Dialog::ZERO ); | ||
| } | ||
| else { | ||
| // Last resort. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It feels off. We must handle everything. Such scenario must be asserted without any assumptions.
| renderer.setCursorPosition( le.getMouseLeftButtonPressedPos() ); | ||
| } | ||
|
|
||
| // right click help for any key on the virtual keyboard. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please be consistent with comments: every comment starts from a capital letter and also always on a new line. Also, it usually ends with a full stop to give a meaning of a complete explanation.
|
|
||
| KeyboardButton( std::string input, const fheroes2::Key kbKey, const fheroes2::Size & buttonSize, const bool isEvilInterface, | ||
| std::function<DialogAction( KeyboardRenderer & )> actionEvent ) | ||
| std::function<DialogAction( KeyboardRenderer & )> actionEvent, std::string helpT = {}, std::string helpD = {} ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not use default values for input arguments. It's usually a risky practice. I also suggest to move these arguments just after input where they logically belong to. In the code we can use {} to indicate empty strings.
| return true; | ||
| } | ||
|
|
||
| // Generic character help (for normal character keys) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we just need to display "Insert this character" with the character, and then assert that both title and description are empty.
Fixes #10152