Skip to content

Commit

Permalink
Fix #199 Correctly restore Keyboard.areRepeatEventsEnabled
Browse files Browse the repository at this point in the history
  • Loading branch information
mezz committed Jul 6, 2016
1 parent f542e86 commit cd1b6c8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Expand Up @@ -5,4 +5,4 @@ curse_project_id=238222

version_major=3
version_minor=7
version_patch=3
version_patch=4
16 changes: 13 additions & 3 deletions src/main/java/mezz/jei/input/GuiTextFieldFilter.java
Expand Up @@ -19,6 +19,7 @@ public class GuiTextFieldFilter extends GuiTextField {
private final List<String> history = new LinkedList<>();
private final HoverChecker hoverChecker;
private ItemFilter itemFilter;
private boolean previousKeyboardRepeatEnabled;

public GuiTextFieldFilter(int componentId, FontRenderer fontRenderer, int x, int y, int width, int height) {
super(componentId, fontRenderer, x, y, width, height);
Expand Down Expand Up @@ -95,11 +96,20 @@ public boolean handleMouseClicked(int mouseX, int mouseY, int mouseButton) {

@Override
public void setFocused(boolean keyboardFocus) {
final boolean previousFocus = isFocused();
super.setFocused(keyboardFocus);
Keyboard.enableRepeatEvents(keyboardFocus);

if (!keyboardFocus) {
saveHistory();
if (previousFocus != keyboardFocus) {
if (keyboardFocus) {
previousKeyboardRepeatEnabled = Keyboard.areRepeatEventsEnabled();
Keyboard.enableRepeatEvents(true);
} else {
Keyboard.enableRepeatEvents(previousKeyboardRepeatEnabled);
}

if (!keyboardFocus) {
saveHistory();
}
}
}

Expand Down

0 comments on commit cd1b6c8

Please sign in to comment.