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

Last change on this file since 994 was 994, checked in by davidb, 8 years ago

Added new Java classes for widgets

File size: 1.6 KB
Line 
1package org.expeditee.items.widgets;
2
3import java.awt.event.ActionEvent;
4import java.awt.event.ActionListener;
5import java.io.File;
6
7import org.expeditee.gui.DisplayIO;
8import org.expeditee.gui.FrameMouseActions;
9import org.expeditee.gui.FreeItems;
10import org.expeditee.items.Item;
11import 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
14public 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}
Note: See TracBrowser for help on using the repository browser.