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