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

Some text field improvements. #8680

Merged
merged 5 commits into from
Jul 24, 2015
Merged

Some text field improvements. #8680

merged 5 commits into from
Jul 24, 2015

Conversation

deniz1a
Copy link
Contributor

@deniz1a deniz1a commented Jul 7, 2015

This is split from #8118.

@phrohdoh
Copy link
Member

phrohdoh commented Jul 7, 2015

What do we gain from this? What is the reasoning behind it?

@chrisforbes
Copy link
Member

This seems vaguely OK to me, but I'd rather you pull the shared handler out into its own (possibly anonymous) function rather than invoking OnClick of another widget.

closeButton.OnClick();
else
{
filenameInput.Text = null;
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems dangerous to me. In general you want to use "" over null when it comes to UI text, and it looks like this could break if this handler runs twice.

Copy link
Member

Choose a reason for hiding this comment

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

Yup, always go for string.Empty.

@deniz1a
Copy link
Contributor Author

deniz1a commented Jul 8, 2015

I put the shared closing statements in an Action variable and used that.

filenameInput.Text = null; works because the set method of Text assigns empty string if the value is null.
https://github.com/OpenRA/OpenRA/blob/bleed/OpenRA.Mods.Common/Widgets/TextFieldWidget.cs#L23

But assigning an empty string directly is better I guess.

@deniz1a
Copy link
Contributor Author

deniz1a commented Jul 8, 2015

This PR does the following:

  • Asset browser: filter text field gets focus by default. Pressing Esc doesn't yield focus. Instead, if text field is empty, it closes the window. If text is not empty, it resets text (makes it empty) and updates filter.
  • Lobby: Pressing Esc resets chat text field if it's not empty, otherwise it closes lobby window. In player name field, when Esc is pressed, text returns to unedited value and focus is yielded.
  • Settings menu Display tab: For both frame limit and player name fields: pressing Esc resets text field and yields focus.

player.Stop();
Ui.CloseWindow();
onExit();
};
Copy link
Member

Choose a reason for hiding this comment

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

Style nits: indented one level too far, and newline after the }; please.

@pchote
Copy link
Member

pchote commented Jul 24, 2015

There are some nice usability improvements here, but there are a few style issues and a couple of bugs that will need to be fixed before we can merge it. Please also split this into individual commits for lobby / settings / asset browser with commit messages that describe what you said above.

@deniz1a
Copy link
Contributor Author

deniz1a commented Jul 24, 2015

I fixed all the issues.

chatTextField.OnEscKey = () =>
{
if (chatTextField.Text.Length == 0)
closeLobby();
Copy link
Member

Choose a reason for hiding this comment

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

We deliberately chose not to do this because accidentally quitting from a server is a lossy activity, and this makes it far too easy to trigger. Please revert this to the previous behaviour.

Text field takes keyboard focus by default.
Esc key resets filter or closes window if text field is empty.
Esc key resets text field to unedited value and yields focus.
Esc key resets text field to unmodified value and yields focus.
@obrakmann
Copy link
Contributor

Looks fine now. 👍

obrakmann added a commit that referenced this pull request Jul 24, 2015
Some text field improvements.
@obrakmann obrakmann merged commit 7d56209 into OpenRA:bleed Jul 24, 2015
@obrakmann
Copy link
Contributor

Changelog

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.

8 participants