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

Fix bug in town window: eating hotkeys even when edit box is not focused #3902

Closed
DorpsGek opened this issue Jun 24, 2010 · 4 comments
Closed
Labels
component: interface This is an interface issue flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)

Comments

@DorpsGek
Copy link
Member

Zuu opened the ticket and wrote:

While testing #3891, SmatZ found a bug in the town window that caused it to eat all hotkeys on his computer even if the edit box was not focused.

The problem was that the 'state' variable in OnKeyPress was not initialized. HandleEditBoxKey will not set state to ES_NOT_HANDLED if the edit box isn't focused.

This patch fix the code of the found town window OnKeyPress function. An alternative solution is to change HandleEditBoxKey so that it always assign state a value. (state is passed as a by-reference parameter to HandleEditBoxKey)

Attachments

Reported version: 1.0.2
Operating system: All


This issue was imported from FlySpray: https://bugs.openttd.org/task/3902
@DorpsGek
Copy link
Member Author

Zuu wrote:

Here is another fix that use an idea that SmatZ had. It changes the behaviour of HandleEditBoxKey so that it will always set state to either ES_NOT_HANDLED or ES_HANDLED. This has been documented in the function documentation.

While it would now be possible to remove all initializations of the state var in simple OnKeyPress-functions, however I've made the decision to keep the initialization there and instead add it to the places where it is missing. This removes the question of how complicated should the function be in order to do a initialization of the state var even if it is not needed, just to make sure it is not forgotten if the function is changed. This simplify the documentation in the wiki as well.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/3902#comment8183

@DorpsGek
Copy link
Member Author

Terkhen wrote:

This bug is probably caused by the "Choose town name before its creation" feature. Since it is also present in 1.0.2, IMO the first patch is preferable to simplify backporting.


This comment was imported from FlySpray: https://bugs.openttd.org/task/3902#comment8184

@DorpsGek
Copy link
Member Author

Zuu wrote:

Then I would suggest using this patch. It is solving the three places in trunk where the 'state' variable is not initialized. The fix for the AIDebug window is not needed in 1.0.2, as the edit box of the AIDebug window does only exist in trunk, but not in the 1.0 series.

I've btw. fixed the wiki so the example code there initialize the state variable.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/3902#comment8185

@DorpsGek
Copy link
Member Author

Terkhen closed the ticket.

Reason for closing: Fixed

In r20139, r20140 and r20141. Thank you for the patch.


This comment was imported from FlySpray: https://bugs.openttd.org/task/3902

@DorpsGek DorpsGek added component: interface This is an interface issue flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) bug labels Apr 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: interface This is an interface issue flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)
Projects
None yet
Development

No branches or pull requests

1 participant