mirror of
https://github.com/carlrobertoh/ProxyAI.git
synced 2026-05-09 02:51:09 +00:00
Change how placeholder text is displayed and hidden (#64)
* Change how placeholder text is displayed and hidden - based on the IntelliJ Platform UI Guidelines https://jetbrains.design/intellij/controls/input_field/#placeholder - remove focus event and listener * Remove color styling on input box text
This commit is contained in:
parent
87dbc42040
commit
e3c748b0fa
1 changed files with 2 additions and 24 deletions
|
|
@ -3,23 +3,19 @@ package ee.carlrobert.codegpt.toolwindow.components;
|
|||
import static ee.carlrobert.codegpt.util.SwingUtils.addShiftEnterInputMap;
|
||||
import static ee.carlrobert.codegpt.util.SwingUtils.createIconButton;
|
||||
|
||||
import com.intellij.ui.JBColor;
|
||||
import com.intellij.ui.components.JBTextArea;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import icons.Icons;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.awt.event.FocusListener;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JScrollPane;
|
||||
|
||||
public class TextArea extends JBTextArea {
|
||||
|
||||
public TextArea(Runnable onSubmit, JScrollPane textAreaScrollPane) {
|
||||
super("Ask me anything...");
|
||||
setForeground(JBColor.GRAY);
|
||||
super();
|
||||
getEmptyText().setText("Ask me anything...");
|
||||
setMargin(JBUI.insets(5));
|
||||
addFocusListener(getFocusListener());
|
||||
addSubmitButton(onSubmit, textAreaScrollPane);
|
||||
addShiftEnterInputMap(this, onSubmit);
|
||||
}
|
||||
|
|
@ -36,22 +32,4 @@ public class TextArea extends JBTextArea {
|
|||
button.addActionListener(submitButtonListener);
|
||||
return button;
|
||||
}
|
||||
|
||||
private FocusListener getFocusListener() {
|
||||
return new FocusListener() {
|
||||
public void focusGained(FocusEvent e) {
|
||||
if (getText().equals("Ask me anything...")) {
|
||||
setText("");
|
||||
setForeground(JBColor.BLACK);
|
||||
}
|
||||
}
|
||||
|
||||
public void focusLost(FocusEvent e) {
|
||||
if (getText().isEmpty()) {
|
||||
setForeground(JBColor.GRAY);
|
||||
setText("Ask me anything...");
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue