Support clicking sort drop down item a second time to reverse sort

This commit is contained in:
drdev
2015-04-12 20:36:48 +00:00
parent 6b59666dab
commit 19ccab3d00
2 changed files with 14 additions and 4 deletions

View File

@@ -187,7 +187,7 @@ public abstract class ItemManager<T extends InventoryItem> extends FContainer im
sortCols.clear();
if (cbxSortOptions != null) {
cbxSortOptions.setChangedHandler(null);
cbxSortOptions.setDropDownItemTap(null);
cbxSortOptions.removeAllItems();
}
@@ -226,10 +226,10 @@ public abstract class ItemManager<T extends InventoryItem> extends FContainer im
}
if (cbxSortOptions != null) {
cbxSortOptions.setChangedHandler(new FEventHandler() {
cbxSortOptions.setDropDownItemTap(new FEventHandler() {
@Override
public void handleEvent(FEvent e) {
model.getCascadeManager().add(cbxSortOptions.getSelectedItem(), false);
model.getCascadeManager().add((ItemColumn)e.getArgs(), false);
model.refreshSort();
ItemManagerConfig.save();
updateView(true, null);

View File

@@ -17,7 +17,7 @@ public class FComboBox<T> extends FTextField implements IComboBox<T> {
private final List<T> items = new ArrayList<T>();
private T selectedItem;
private final DropDown dropDown = new DropDown();
private FEventHandler dropDownChangeHandler;
private FEventHandler dropDownItemTap, dropDownChangeHandler;
public FComboBox() {
initialize();
@@ -134,6 +134,13 @@ public class FComboBox<T> extends FTextField implements IComboBox<T> {
return false; //don't allow editing text
}
public FEventHandler getDropDownItemTap() {
return dropDownItemTap;
}
public void setDropDownItemTap(FEventHandler itemTap0) {
dropDownItemTap = itemTap0;
}
public FEventHandler getDropDownChangeHandler() {
return dropDownChangeHandler;
}
@@ -193,6 +200,9 @@ public class FComboBox<T> extends FTextField implements IComboBox<T> {
FMenuItem menuItem = new FMenuItem(item.toString(), new FEventHandler() {
@Override
public void handleEvent(FEvent e) {
if (dropDownItemTap != null) {
dropDownItemTap.handleEvent(new FEvent(FComboBox.this, FEventType.TAP, item));
}
if (item != selectedItem) {
setSelectedItem(item);
if (dropDownChangeHandler != null) {