Skip to content

Conversation

@jrcleeman
Copy link
Contributor

@jrcleeman jrcleeman commented Oct 1, 2025

Fixes #10152

image

Copy link
Contributor

@github-actions github-actions bot left a 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)

@ihhub
Copy link
Owner

ihhub commented Oct 2, 2025

Hi @jrcleeman , please fix code style issues and also clang-tidy problems.

@ihhub ihhub marked this pull request as draft October 2, 2025 06:28
@ihhub
Copy link
Owner

ihhub commented Oct 4, 2025

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 struct KeyboardButton to contain a description. To save memory we can leave the description empty for all "normal" buttons but to add one for special ones. So, the logic for popup message would it: if description is set then display it, otherwise use generic description.

@ihhub ihhub marked this pull request as ready for review October 17, 2025 08:42
@ihhub ihhub requested review from Districh-ru and ihhub October 17, 2025 08:42
@ihhub ihhub added improvement New feature, request or improvement ui UI/GUI related stuff labels Oct 17, 2025
@ihhub ihhub added this to the 1.1.12 milestone Oct 17, 2025
@ihhub ihhub changed the title Add right click popup for keyboard buttons (Fixes #10152) Add right click popup for keyboard buttons Oct 22, 2025
Copy link
Owner

@ihhub ihhub left a 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"
Copy link
Owner

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 ) {
Copy link
Owner

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.
Copy link
Owner

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.
Copy link
Owner

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 = {} )
Copy link
Owner

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)
Copy link
Owner

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.

@ihhub ihhub modified the milestones: 1.1.12, 1.1.13 Nov 9, 2025
@ihhub ihhub modified the milestones: 1.1.13, 1.2.0 Dec 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement New feature, request or improvement ui UI/GUI related stuff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add popup messages for the Virtual Keyboard buttons

2 participants