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

Last change on this file since 1102 was 1102, checked in by davidb, 6 years ago

Reworking of the code-base to separate logic from graphics. This version of Expeditee now supports a JFX graphics as an alternative to SWING

File size: 1.6 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,
14 * whatever is currently being picked up by the mouse is destroyed.
15 *
16 * @author cts16
17 */
18public 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}
Note: See TracBrowser for help on using the repository browser.