mirror of
https://gitlab.com/2009scape/rt4-client.git
synced 2025-12-18 20:40:20 -07:00
Fix search users
This commit is contained in:
parent
215263a129
commit
df091ac94b
5 changed files with 32 additions and 197 deletions
|
|
@ -11,12 +11,13 @@ import java.awt.datatransfer.DataFlavor
|
|||
import java.awt.event.*
|
||||
import javax.swing.*
|
||||
|
||||
open class SearchField(
|
||||
protected val onSearch: (String) -> Unit,
|
||||
class SearchField(
|
||||
private val parentPanel: JPanel,
|
||||
private val onSearch: (String) -> Unit,
|
||||
private val placeholderText: String = "Search...",
|
||||
private val fieldWidth: Int = 230,
|
||||
private val fieldHeight: Int = 30,
|
||||
private val viewName: String? = null
|
||||
private val viewName: String? = ""
|
||||
) : Canvas() {
|
||||
|
||||
private var cursorVisible: Boolean = true
|
||||
|
|
@ -81,9 +82,7 @@ open class SearchField(
|
|||
SwingUtilities.invokeLater {
|
||||
repaint()
|
||||
}
|
||||
} catch (ex: Exception) {
|
||||
// Ignore clipboard errors
|
||||
}
|
||||
} catch (_: Exception) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -91,9 +90,11 @@ open class SearchField(
|
|||
})
|
||||
|
||||
addMouseListener(object : MouseAdapter() {
|
||||
// Clicked the search field 'x' button
|
||||
override fun mouseClicked(e: MouseEvent) {
|
||||
if (e.x > width - 20 && e.y < 20) {
|
||||
text = ""
|
||||
triggerSearch()
|
||||
SwingUtilities.invokeLater {
|
||||
repaint()
|
||||
}
|
||||
|
|
@ -132,10 +133,10 @@ open class SearchField(
|
|||
|
||||
// Draw placeholder text if field is empty, otherwise draw actual text
|
||||
if (currentText.isEmpty()) {
|
||||
g.color = Color.GRAY // Use a lighter color for placeholder text
|
||||
g.color = Color.GRAY // lighter color for placeholder
|
||||
g.drawString(placeholderText, 30, 20)
|
||||
} else {
|
||||
g.color = foreground // Use normal color for actual text
|
||||
g.color = foreground // normal color for user entered text
|
||||
g.drawString(currentText, 30, 20)
|
||||
}
|
||||
|
||||
|
|
@ -164,6 +165,8 @@ open class SearchField(
|
|||
text = query
|
||||
repaint()
|
||||
onSearch(query)
|
||||
} else {
|
||||
onSearch(query) // Call with empty string for clearing filters
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue