From 8d413ddb2f6efd12929fde11bebca8c6ae16642f Mon Sep 17 00:00:00 2001 From: Dirk Lemmermann Date: Fri, 10 May 2024 11:15:57 +0200 Subject: [PATCH] Update SearchTextField default behaviors and refactor documentation The default behavior for adding search history on 'enter' key press in the SearchTextField has been changed to `true`. Additionally, the documentation comments have been slightly refactored to improve readability. Changes also involve minor code restructuring for aesthetics and consistency. --- .../java/com/dlsc/gemsfx/SearchTextField.java | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/gemsfx/src/main/java/com/dlsc/gemsfx/SearchTextField.java b/gemsfx/src/main/java/com/dlsc/gemsfx/SearchTextField.java index eba8bd59..3eea33e4 100644 --- a/gemsfx/src/main/java/com/dlsc/gemsfx/SearchTextField.java +++ b/gemsfx/src/main/java/com/dlsc/gemsfx/SearchTextField.java @@ -37,22 +37,21 @@ import java.util.logging.Logger; /** - * A custom text field specifically designed for search functionality. - * This class enhances a text field with features such as a history of search terms, - * an optional history popup, and custom icons for search and clear operations. + * A custom text field specifically designed for search functionality. This class enhances a text field with features + * such as a history of search terms, an optional history popup, and custom icons for search and clear operations. *

- * By default, when the user presses the Enter key (triggering the onAction event), the text is added to the history. + * By default, when the user presses the "enter" key (triggering the onAction event), the text is added to the history. * This behavior can be disabled by setting the {@link #addHistoryOnEnterProperty()}. *
- * Additionally, history can be manually - * added based on user actions, such as after typing text and selecting an item from a ListView or TableView that displays results, - * or through other interactions, by calling the {@link #addHistory} method to add the current text to the history. + * Additionally, history can be manually added based on user actions, such as after typing text and selecting an item + * from a ListView or TableView that displays results, or through other interactions, by calling the {@link #addHistory} + * method to add the current text to the history. */ public class SearchTextField extends CustomTextField { private static final int DEFAULT_MAX_HISTORY_SIZE = 30; private static final boolean ENABLE_HISTORY_POPUP = true; - private static final boolean DEFAULT_ADD_HISTORY_ON_ENTER = false; + private static final boolean DEFAULT_ADD_HISTORY_ON_ENTER = true; private static final PseudoClass DISABLED_POPUP_PSEUDO_CLASS = PseudoClass.getPseudoClass("disabled-popup"); private static final PseudoClass HISTORY_POPUP_SHOWING_PSEUDO_CLASS = PseudoClass.getPseudoClass("history-popup-showing"); @@ -72,14 +71,14 @@ public SearchTextField(boolean round) { getStyleClass().add("search-text-field"); setPromptText("Search..."); + Label placeholder = new Label("No history available."); placeholder.getStyleClass().add("default-placeholder"); setHistoryPlaceholder(placeholder); - setEnableHistoryPopup(false); searchIconWrapper = createLeftNode(); - setLeft(searchIconWrapper); + setLeft(searchIconWrapper); setRight(createRightNode()); addEventHandlers();