Merge pull request #11183 from DSerp/quest-filter-fix
quest list: stop chat input from closing when pressing enter
This commit is contained in:
@@ -106,7 +106,7 @@ public class ChatboxTextInput extends ChatboxInput implements KeyListener, Mouse
|
|||||||
private Runnable onClose = null;
|
private Runnable onClose = null;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private Consumer<String> onDone = null;
|
private Predicate<String> onDone = null;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private Consumer<String> onChanged = null;
|
private Consumer<String> onChanged = null;
|
||||||
@@ -235,6 +235,20 @@ public class ChatboxTextInput extends ChatboxInput implements KeyListener, Mouse
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ChatboxTextInput onDone(Consumer<String> onDone)
|
public ChatboxTextInput onDone(Consumer<String> onDone)
|
||||||
|
{
|
||||||
|
this.onDone = (s) ->
|
||||||
|
{
|
||||||
|
onDone.accept(s);
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the user attempts to close the input by pressing enter
|
||||||
|
* Return false to cancel the close
|
||||||
|
*/
|
||||||
|
public ChatboxTextInput onDone(Predicate<String> onDone)
|
||||||
{
|
{
|
||||||
this.onDone = onDone;
|
this.onDone = onDone;
|
||||||
return this;
|
return this;
|
||||||
@@ -753,9 +767,9 @@ public class ChatboxTextInput extends ChatboxInput implements KeyListener, Mouse
|
|||||||
break;
|
break;
|
||||||
case KeyEvent.VK_ENTER:
|
case KeyEvent.VK_ENTER:
|
||||||
ev.consume();
|
ev.consume();
|
||||||
if (onDone != null)
|
if (onDone != null && !onDone.test(getValue()))
|
||||||
{
|
{
|
||||||
onDone.accept(getValue());
|
return;
|
||||||
}
|
}
|
||||||
chatboxPanelManager.close();
|
chatboxPanelManager.close();
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ import java.util.Collection;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.function.Consumer;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
@@ -407,7 +408,7 @@ public class BankTagsPlugin extends Plugin implements MouseWheelListener, KeyLis
|
|||||||
chatboxPanelManager.openTextInput(name + " tags:<br>(append " + VAR_TAG_SUFFIX + " for variation tag)")
|
chatboxPanelManager.openTextInput(name + " tags:<br>(append " + VAR_TAG_SUFFIX + " for variation tag)")
|
||||||
.addCharValidator(FILTERED_CHARS)
|
.addCharValidator(FILTERED_CHARS)
|
||||||
.value(initialValue)
|
.value(initialValue)
|
||||||
.onDone((newValue) ->
|
.onDone((Consumer<String>) (newValue) ->
|
||||||
clientThread.invoke(() ->
|
clientThread.invoke(() ->
|
||||||
{
|
{
|
||||||
// Split inputted tags to vartags (ending with *) and regular tags
|
// Split inputted tags to vartags (ending with *) and regular tags
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ import java.util.Iterator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.function.Consumer;
|
||||||
import java.util.function.IntPredicate;
|
import java.util.function.IntPredicate;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
@@ -268,7 +269,7 @@ public class TabInterface
|
|||||||
|
|
||||||
chatboxPanelManager.openTextInput((inventory ? "Inventory " : "Equipment ") + " tags:")
|
chatboxPanelManager.openTextInput((inventory ? "Inventory " : "Equipment ") + " tags:")
|
||||||
.addCharValidator(FILTERED_CHARS)
|
.addCharValidator(FILTERED_CHARS)
|
||||||
.onDone((newTags) ->
|
.onDone((Consumer<String>) (newTags) ->
|
||||||
clientThread.invoke(() ->
|
clientThread.invoke(() ->
|
||||||
{
|
{
|
||||||
final List<String> tags = Text.fromCSV(newTags.toLowerCase());
|
final List<String> tags = Text.fromCSV(newTags.toLowerCase());
|
||||||
@@ -290,7 +291,7 @@ public class TabInterface
|
|||||||
case NewTab.NEW_TAB:
|
case NewTab.NEW_TAB:
|
||||||
chatboxPanelManager.openTextInput("Tag name")
|
chatboxPanelManager.openTextInput("Tag name")
|
||||||
.addCharValidator(FILTERED_CHARS)
|
.addCharValidator(FILTERED_CHARS)
|
||||||
.onDone((tagName) -> clientThread.invoke(() ->
|
.onDone((Consumer<String>) (tagName) -> clientThread.invoke(() ->
|
||||||
{
|
{
|
||||||
if (!Strings.isNullOrEmpty(tagName))
|
if (!Strings.isNullOrEmpty(tagName))
|
||||||
{
|
{
|
||||||
@@ -908,7 +909,7 @@ public class TabInterface
|
|||||||
{
|
{
|
||||||
chatboxPanelManager.openTextInput("Enter new tag name for tag \"" + oldTag + "\":")
|
chatboxPanelManager.openTextInput("Enter new tag name for tag \"" + oldTag + "\":")
|
||||||
.addCharValidator(FILTERED_CHARS)
|
.addCharValidator(FILTERED_CHARS)
|
||||||
.onDone((newTag) -> clientThread.invoke(() ->
|
.onDone((Consumer<String>) (newTag) -> clientThread.invoke(() ->
|
||||||
{
|
{
|
||||||
if (!Strings.isNullOrEmpty(newTag) && !newTag.equalsIgnoreCase(oldTag))
|
if (!Strings.isNullOrEmpty(newTag) && !newTag.equalsIgnoreCase(oldTag))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -196,6 +196,7 @@ public class FairyRingPlugin extends Plugin
|
|||||||
searchBtn.setOnOpListener((JavaScriptCallback) this::menuClose);
|
searchBtn.setOnOpListener((JavaScriptCallback) this::menuClose);
|
||||||
searchInput = chatboxPanelManager.openTextInput("Filter fairy rings")
|
searchInput = chatboxPanelManager.openTextInput("Filter fairy rings")
|
||||||
.onChanged(s -> clientThread.invokeLater(() -> updateFilter(s)))
|
.onChanged(s -> clientThread.invokeLater(() -> updateFilter(s)))
|
||||||
|
.onDone(s -> false)
|
||||||
.onClose(() ->
|
.onClose(() ->
|
||||||
{
|
{
|
||||||
clientThread.invokeLater(() -> updateFilter(""));
|
clientThread.invokeLater(() -> updateFilter(""));
|
||||||
|
|||||||
@@ -321,6 +321,7 @@ public class MusicPlugin extends Plugin
|
|||||||
musicSearchButton.setOnOpListener((JavaScriptCallback) e -> closeSearch());
|
musicSearchButton.setOnOpListener((JavaScriptCallback) e -> closeSearch());
|
||||||
searchInput = chatboxPanelManager.openTextInput("Search music list")
|
searchInput = chatboxPanelManager.openTextInput("Search music list")
|
||||||
.onChanged(s -> clientThread.invokeLater(() -> updateFilter(s.trim())))
|
.onChanged(s -> clientThread.invokeLater(() -> updateFilter(s.trim())))
|
||||||
|
.onDone(s -> false)
|
||||||
.onClose(() ->
|
.onClose(() ->
|
||||||
{
|
{
|
||||||
clientThread.invokeLater(() -> updateFilter(""));
|
clientThread.invokeLater(() -> updateFilter(""));
|
||||||
|
|||||||
@@ -233,6 +233,7 @@ public class QuestListPlugin extends Plugin
|
|||||||
questSearchButton.setOnOpListener((JavaScriptCallback) e -> closeSearch());
|
questSearchButton.setOnOpListener((JavaScriptCallback) e -> closeSearch());
|
||||||
searchInput = chatboxPanelManager.openTextInput("Search quest list")
|
searchInput = chatboxPanelManager.openTextInput("Search quest list")
|
||||||
.onChanged(s -> clientThread.invokeLater(() -> updateFilter(s)))
|
.onChanged(s -> clientThread.invokeLater(() -> updateFilter(s)))
|
||||||
|
.onDone(s -> false)
|
||||||
.onClose(() ->
|
.onClose(() ->
|
||||||
{
|
{
|
||||||
clientThread.invokeLater(() -> updateFilter(""));
|
clientThread.invokeLater(() -> updateFilter(""));
|
||||||
|
|||||||
Reference in New Issue
Block a user