Skip to content
Snippets Groups Projects
Commit 7c3e9316 authored by Robert Goldmann's avatar Robert Goldmann
Browse files

Fixed #61 - allow editing of categories via double click

parent ce09d318
Branches
Tags
No related merge requests found
...@@ -12,6 +12,7 @@ import fontAwesome.FontIconType; ...@@ -12,6 +12,7 @@ import fontAwesome.FontIconType;
import javafx.application.Platform; import javafx.application.Platform;
import javafx.beans.value.ChangeListener; import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue; import javafx.beans.value.ObservableValue;
import javafx.event.EventHandler;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader; import javafx.fxml.FXMLLoader;
import javafx.scene.Parent; import javafx.scene.Parent;
...@@ -20,6 +21,7 @@ import javafx.scene.control.Button; ...@@ -20,6 +21,7 @@ import javafx.scene.control.Button;
import javafx.scene.control.Label; import javafx.scene.control.Label;
import javafx.scene.control.ListCell; import javafx.scene.control.ListCell;
import javafx.scene.control.ListView; import javafx.scene.control.ListView;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.AnchorPane; import javafx.scene.layout.AnchorPane;
import javafx.stage.Modality; import javafx.stage.Modality;
import javafx.stage.Stage; import javafx.stage.Stage;
...@@ -44,7 +46,23 @@ public class CategoryController implements Refreshable ...@@ -44,7 +46,23 @@ public class CategoryController implements Refreshable
@Override @Override
public ListCell<Category> call(ListView<Category> param) public ListCell<Category> call(ListView<Category> param)
{ {
return new CategoryCell(thisController); CategoryCell cell = new CategoryCell(thisController);
cell.addEventFilter(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>()
{
@Override
public void handle(MouseEvent event)
{
if(event.getClickCount() == 2)
{
// don't allow editing of category "none"
if(cell.getItem().getID() != 1)
{
newCategory(true, cell.getItem());
}
}
}
});
return cell;
} }
}); });
......
...@@ -65,11 +65,10 @@ public class PaymentController implements Refreshable ...@@ -65,11 +65,10 @@ public class PaymentController implements Refreshable
{ {
if(event.getClickCount() == 2) if(event.getClickCount() == 2)
{ {
PaymentCell c = (PaymentCell)event.getSource();
// don't allow editing of payment "rest" // don't allow editing of payment "rest"
if(c.getItem().getCategoryID() != 2) if(cell.getItem().getCategoryID() != 2)
{ {
payment(!c.getItem().isIncome(), true, c.getItem()); payment(!cell.getItem().isIncome(), true, cell.getItem());
} }
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment