Skip to content

Commit 5b44f13

Browse files
committed
add "del" hotkey functionality
1 parent 92daa5f commit 5b44f13

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Fruit_Jam/Fruit_Jam_Logic_Gates/workspace.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,20 @@ def handle_key_press(self, key_bytes, mouse_x, mouse_y):
407407
if self.moving_entity is not None:
408408
self.moving_entity = None
409409
self.mouse_moving_tg.hidden = True
410+
else:
411+
# apply offset value based on scroll position
412+
mouse_x -= self._scroll_x * self.tilegrid.tile_width * 1
413+
mouse_y -= self._scroll_y * self.tilegrid.tile_height * 1
414+
415+
# calculate tile coordinates
416+
tile_x = mouse_x // self.tilegrid.tile_width
417+
tile_y = mouse_y // self.tilegrid.tile_height
418+
419+
# get the entity at the coordinates if there is one
420+
hovered_entity = self.entity_at((tile_x, tile_y))
421+
422+
if hovered_entity is not None:
423+
self.remove_entity(hovered_entity)
410424

411425
# eyedropper or pipette action
412426
elif action == "eyedropper":

0 commit comments

Comments
 (0)