source: trunk/src/org/expeditee/items/widgets/RubbishBin.java@ 1176

Last change on this file since 1176 was 1176, checked in by bln4, 6 years ago
File size: 1.7 KB
Line 
1package org.expeditee.items.widgets;
2
3import java.awt.event.ActionEvent;
4import java.awt.event.ActionListener;
5
6import org.expeditee.gio.gesture.StandardGestureActions;
7import org.expeditee.gui.DisplayController;
8import org.expeditee.gui.FreeItems;
9import org.expeditee.items.Item;
10import org.expeditee.items.Text;
11
12/**
13* When the Rubbish Bin Widget is clicked by any of the mouse buttons, whatever
14 * is currently being picked up by the mouse is destroyed.
15 *
16 * @author cts16
17 */
18public class RubbishBin extends ButtonWidget {
19 public RubbishBin(Text source, String[] args) {
20 super(80, "org/expeditee/assets/images/bin.svg", source, args);
21
22 clicked_.addActionListener(new ActionListener() {
23 @Override
24 public void actionPerformed(ActionEvent e) {
25 System.err.println("Rubbish Bin action performed");
26 }
27 });
28 }
29
30 @Override
31 public boolean ItemsLeftClickDropped() {
32 // Find what the mouse was holding at the time and delete it
33 Item freeItems = FreeItems.getItemAttachedToCursor();
34
35 if (freeItems != null) {
36 freeItems.setParent(DisplayController.getCurrentFrame());
37
38 try {
39 StandardGestureActions.delete(freeItems, null, null, false);
40 } catch (Exception e) {
41 e.printStackTrace();
42 }
43 }
44
45 return true;
46 }
47
48
49 @Override
50 protected String[] getArgs() {
51 // TODO Auto-generated method stub
52 return null;
53 }
54
55 /**
56 * This should be a generic method for any widget that is clicked while an item
57 * is being held.
58 */
59 @Override
60 public boolean itemHeldWhileClicked(Widget iw) {
61 ItemsLeftClickDropped();
62
63 return true;
64 }
65
66 @Override
67 public boolean getdropInteractableStatus() {
68 return true;
69 }
70}
Note: See TracBrowser for help on using the repository browser.