Merge pull request #358 from ludovic111/fix/inventory-shift

Shift-click on every container screen, even when Shift is pressed after it opens
This commit is contained in:
Ludovic Marie
2026-10-15 19:38:36 +02:00
committed by GitHub
5 changed files with 24 additions and 11 deletions
+7 -1
View File
@@ -4720,6 +4720,12 @@ impl Game<'_> {
self.physical_keys.contains(&KeyCode::ShiftLeft)
|| self.physical_keys.contains(&KeyCode::ShiftRight)
}
/// `Minecraft.hasControlDown`: the physical Control keys, whatever the
/// sprint key is bound or toggled to.
pub(super) fn has_control_down(&self) -> bool {
self.physical_keys.contains(&KeyCode::ControlLeft)
|| self.physical_keys.contains(&KeyCode::ControlRight)
}
/// `hasClickedOutside` of the open screen at the cursor.
fn clicked_outside(&self, batch: &HudBatch) -> bool {
use horizon_client::container_screen::{Book, Image, clicked_outside};
@@ -7962,7 +7968,7 @@ impl Game<'_> {
{
return;
}
let shift = self.keys.contains(&KeyCode::ShiftLeft);
let shift = self.has_shift_down();
let items = self.creative_screen.items(&self.res.names);
let first = self.creative_screen.first_row(&self.res.names);
for r in 0..5 {
+12 -2
View File
@@ -653,7 +653,14 @@ impl Game<'_> {
"gpu_reserved_bytes": memory.as_ref().map(|m| m.total_reserved_bytes),
})
});
json!({
// The keyboard as the OS reports it (screens read Shift and Ctrl here).
let mut physical_keys: Vec<_> = self
.physical_keys
.iter()
.map(|k| format!("{k:?}"))
.collect();
physical_keys.sort();
let mut status = json!({
"screen": self.screen_name(),
"debug": {
"overlay": self.debug,
@@ -674,6 +681,7 @@ impl Game<'_> {
"held": self.held().map(|s| json!({ "item": &*s.item, "count": s.count })),
"offhand": self.offhand.as_ref().map(|s| json!({ "item": &*s.item, "count": s.count, "damage": s.damage })),
"keys": self.keys.iter().map(|k| format!("{k:?}")).collect::<Vec<_>>(),
// The keyboard as the OS reports it (Shift and Ctrl in screens).
"fps": self.fps,
"frames": self.frames,
"ticks": self.ticks,
@@ -705,7 +713,9 @@ impl Game<'_> {
})),
"uptime_seconds": self.started.elapsed().as_secs_f64(),
"server": self.remote_status(),
})
});
status["physical_keys"] = json!(physical_keys);
status
}
}
+1 -2
View File
@@ -224,8 +224,7 @@ impl Game<'_> {
let Some(slot) = self.slot_at(&batch, self.cursor.0, self.cursor.1) else {
return true;
};
let shift = self.keys.contains(&winit::keyboard::KeyCode::ShiftLeft)
|| self.keys.contains(&winit::keyboard::KeyCode::ShiftRight);
let shift = self.has_shift_down();
if shift {
self.mount_quick_move(slot);
} else if slot >= SADDLE {
@@ -173,12 +173,12 @@ impl Game<'_> {
}
/// A key press while the search box has focus.
pub(super) fn recipe_key(&mut self, event: &winit::event::KeyEvent) {
use winit::keyboard::{KeyCode, PhysicalKey};
use winit::keyboard::PhysicalKey;
if let Some(shortcut) = self.edit_shortcut(event) {
self.recipe_shortcut(shortcut);
return;
}
let ctrl = self.keys.contains(&KeyCode::ControlLeft);
let ctrl = self.has_control_down();
let shift = self.has_shift_down();
let Some(search) = self.recipe_ui.search.as_mut() else {
return;
@@ -888,8 +888,7 @@ impl Game<'_> {
self.draw_book_panel(batch, book_type);
}
fn shift_down_or_ctrl(&self) -> bool {
use winit::keyboard::KeyCode;
self.keys.contains(&KeyCode::ControlLeft) || self.keys.contains(&KeyCode::ControlRight)
self.has_control_down()
}
/// `GhostSlots.extractRenderState`, among the container's slots.
fn draw_ghost(&mut self, batch: &mut HudBatch, book_type: BookType) {
+1 -2
View File
@@ -1061,8 +1061,7 @@ impl Game<'_> {
let batch = HudBatch::new(size);
let (ox, oy) = self.inventory_origin(&batch);
let local = (self.cursor.0 - ox, self.cursor.1 - oy);
let shift = self.keys.contains(&winit::keyboard::KeyCode::ShiftLeft)
|| self.keys.contains(&winit::keyboard::KeyCode::ShiftRight);
let shift = self.has_shift_down();
if let Some(kind) = self.station.as_ref().map(|s| s.kind) {
if kind == Kind::Merchant && !right && self.merchant_click(local) {
return true;