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