From f52d66d721d24ea7bde15b11a7a9865cc4c4064a Mon Sep 17 00:00:00 2001 From: Imbris Date: Thu, 9 Apr 2020 22:59:28 -0400 Subject: [PATCH] Fix selecting and remove amount text when dragging --- common/src/comp/inventory/slot.rs | 2 +- voxygen/src/ui/widgets/slot.rs | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/common/src/comp/inventory/slot.rs b/common/src/comp/inventory/slot.rs index 25730c626b..6144a3b6d5 100644 --- a/common/src/comp/inventory/slot.rs +++ b/common/src/comp/inventory/slot.rs @@ -246,5 +246,5 @@ pub fn unequip(slot: EquipSlot, inventory: &mut Inventory, loadout: &mut Loadout loadout_remove(slot, loadout) // Remove item from loadout .and_then(|i| inventory.push(i)) // Insert into inventory .and_then(|i| loadout_insert(slot, i, loadout)) // If that fails put back in loadout - .unwrap(); // Never fails + .unwrap_none(); // Never fails } diff --git a/voxygen/src/ui/widgets/slot.rs b/voxygen/src/ui/widgets/slot.rs index 0da5ceae01..e1ba13e862 100644 --- a/voxygen/src/ui/widgets/slot.rs +++ b/voxygen/src/ui/widgets/slot.rs @@ -255,11 +255,10 @@ where }; } - // If not dragging and the mouse is down and started on this slot start dragging - let input = &ui.global_input().current; - if let mouse::ButtonPosition::Down(_, Some(id)) = input.mouse.buttons.left() { + // If not dragging and there is a drag event on this slot start dragging + if ui.widget_input(widget).drags().left().next().is_some() { match self.state { - ManagerState::Selected(_, _) | ManagerState::Idle if widget == *id => { + ManagerState::Selected(_, _) | ManagerState::Idle => { // Start dragging if widget is filled if let Some(img) = content_img { self.state = ManagerState::Dragging(widget, slot, img); @@ -459,7 +458,11 @@ where }; // Get amount (None => no amount text) - let amount = slot_key.amount(content_source); + let amount = if let Interaction::Dragging = interaction { + None // Don't show amount if being dragged + } else { + slot_key.amount(content_source) + }; // Get slot widget dimensions and position let (x, y, w, h) = rect.x_y_w_h();