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

Android: Add field_enter_after_edit[] formspec element #13836

Merged
merged 7 commits into from Oct 1, 2023

Conversation

grorp
Copy link
Member

@grorp grorp commented Sep 23, 2023

The problem

The other day, there was a discussion on Discord about automatically submitting formspecs when closing the Android text input dialog. Here is a small excerpt:

rollerozxa: someone raised an issue to me about rollertest that some settings wouldn't save in the new dialog. in reality it's caused by the fact you can't easily set settings with an input dialog without pressing the set button on android

rollerozxa: on desktop you're able to simply press enter and it will be set, so it would be neat if there could be a little hack that automatically presses enter on input boxes once submitted from the native dialog (either just in the settings dialog or everywhere)

grorp: Doing this (automatically pressing enter when closing the input dialog) everywhere would cause problems in the "Join Game" tab. You'd enter your username, exit the input dialog, and then Minetest would automatically try to join the server. You wouldn't even have a chance to enter a password.

rollerozxa: yeah it would need to be enabled per formspec I think

The discussion starts at https://discord.com/channels/369122544273588224/369137254641303560/1152532281408372788.

The solution

This PR introduces a new formspec element:

### `field_enter_after_edit[<name>;<enter_after_edit>]`

* Only affects Android clients.
* `<name>` is the name of the field.
* If `<enter_after_edit>` is true, pressing the "Done" button in the Android
  text input dialog will simulate an <kbd>Enter</kbd> keypress.
* Defaults to false when not specified (i.e. no tag for a field).

This also works for textareas, btw. There are already many use cases for this in builtin alone. I've enabled enter_after_edit for the following fields:

  • Serverlist search
  • ContentDB search
  • New settings dialog search
  • New settings dialog settings
  • Devtest "chest of everything" / "bag of everything" search

I'm open to suggestions for better solutions to this problem.

To do

This PR is a Ready for Review.

How to test

Verify that pressing the "Done" button in the Android text input dialog still doesn't trigger an Enter keypress by default. Verify that it does trigger an Enter keypress in the cases mentioned above.

CC @rollerozxa

@rollerozxa
Copy link
Member

Haven't tested it but looks good and should fix the issue I was describing, thanks!

Copy link
Member

@srifqi srifqi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this PR. It looks good to me.

src/gui/guiFormSpecMenu.cpp Show resolved Hide resolved
Co-authored-by: Muhammad Rifqi Priyo Susanto <muhammadrifqipriyosusanto@gmail.com>
@grorp
Copy link
Member Author

grorp commented Sep 28, 2023

Thank you for reviewing!

A question for the formspec gurus: Do I have to bump the formspec version in this PR? I don't think so since I haven't changed any existing elements, I've only added a new one, but I'm not sure.

@grorp
Copy link
Member Author

grorp commented Sep 28, 2023

I've increased the formspec version now.
https://irc.minetest.net/minetest-dev/2023-09-28#i_6118407

@grorp grorp requested a review from srifqi September 28, 2023 17:52
@grorp
Copy link
Member Author

grorp commented Sep 30, 2023

Marked the element as experimental according to a discussion on IRC.
https://irc.minetest.net/minetest-dev/2023-09-30#i_6118679

@grorp grorp merged commit 56965bc into minetest:master Oct 1, 2023
15 checks passed
Zughy pushed a commit to Zughy/minetest that referenced this pull request Oct 8, 2023
@Montandalar
Copy link
Contributor

Montandalar commented Oct 29, 2023

I'm glad you were able to have a fruitful discussion on Discord, but viewing that conversation requires an account, and even with being logged in, I get a "no text channels" error message. I assume I need to join the server, but the server information wasn't given.

In contrast, IRC discussions all get logged and are easily viewable on irc.minetest.net. Thankfully, you included the relevant parts of discussion here. I just hope that if you're going to continue using Discord for these kinds of conversations, you always include all the important info on GitHub. But #minetest-dev would be good to use in my opinion.

Edit: Okay, to my surprise, the Discord is listed on minetest.net. Whatever I think of that, it's still really annoying to need an account with a 3rd party to view conversations.

@grorp grorp deleted the field-enter-after-edit branch December 18, 2023 16:39
kawogi pushed a commit to kawogi/minetest that referenced this pull request Dec 19, 2023
cosin15 pushed a commit to cosin15/minetest that referenced this pull request Feb 24, 2024
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.

None yet

4 participants