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