Merge pull request #395 from ludovic111/fix/creative-search-select
Clicking a creative search result selects the query
This commit is contained in:
@@ -223,6 +223,10 @@ impl AppendSelection {
|
||||
pub fn covers(&self, id: FieldId, value: &str) -> bool {
|
||||
self.0.as_ref().is_some_and(|(i, v)| *i == id && v == value)
|
||||
}
|
||||
/// Select the whole `value` of field `id`, as Select All does.
|
||||
pub fn select(&mut self, id: FieldId, value: &str) {
|
||||
self.0 = Some((id, value.to_owned()));
|
||||
}
|
||||
/// Before typing or a backspace: an all-selected value is cleared (true).
|
||||
pub fn take(&mut self, id: FieldId, value: &mut String) -> bool {
|
||||
let covered = self.covers(id, value);
|
||||
@@ -247,7 +251,7 @@ impl AppendSelection {
|
||||
let covered = self.covers(id, value);
|
||||
match shortcut {
|
||||
EditShortcut::SelectAll => {
|
||||
self.0 = Some((id, value.clone()));
|
||||
self.select(id, value);
|
||||
false
|
||||
}
|
||||
EditShortcut::Copy => {
|
||||
|
||||
@@ -4375,6 +4375,12 @@ impl Game<'_> {
|
||||
input: horizon_client::menu::Input,
|
||||
) {
|
||||
use horizon_client::creative::{DisplayClick, click_display};
|
||||
if self.creative_screen.tab().search {
|
||||
// CreativeModeInventoryScreen.slotClicked: moveCursorToEnd, then
|
||||
// setHighlightPos(0), so typing replaces the whole query.
|
||||
let search = &self.creative_screen.search;
|
||||
self.text_selection.select(("creative.search", 0), search);
|
||||
}
|
||||
let items = self.creative_screen.items(&self.res.names);
|
||||
let first = self.creative_screen.first_row(&self.res.names);
|
||||
let shown = items.get(first * 9 + slot - Creative::DISPLAY);
|
||||
|
||||
@@ -425,8 +425,8 @@ impl Game<'_> {
|
||||
self.recipe_text(Some(text), false)
|
||||
}
|
||||
Screen::Creative if self.creative_screen.tab().search => {
|
||||
self.creative_screen.search.push_str(text);
|
||||
self.creative_screen.scroll = 0.0;
|
||||
// As typed: replaces a selected query, keeps the length limit.
|
||||
self.creative_search_edit(Some(text), false)
|
||||
}
|
||||
_ => {
|
||||
return Err(
|
||||
|
||||
Reference in New Issue
Block a user