Fixed drag and drop
This commit is contained in:
parent
3fe22b06be
commit
c548793523
|
@ -109,6 +109,7 @@ module TK.SpaceTac.UI {
|
|||
if (this.applyDragDrop(this.container, destination, false)) {
|
||||
this.container = destination;
|
||||
this.snapToContainer();
|
||||
this.setupDragDrop();
|
||||
this.sheet.refresh(); // TODO Only if required (destination is "virtual")
|
||||
} else {
|
||||
this.snapToContainer();
|
||||
|
@ -134,7 +135,6 @@ module TK.SpaceTac.UI {
|
|||
} else if (possible) {
|
||||
if (source.removeEquipment(this, destination, false)) {
|
||||
if (destination.addEquipment(this, source, false)) {
|
||||
this.setupDragDrop();
|
||||
return true;
|
||||
} else {
|
||||
console.error("Destination container refused to accept equipment", this, source, destination);
|
||||
|
|
|
@ -127,8 +127,14 @@ module TK.SpaceTac.UI.Specs {
|
|||
|
||||
testgame.view.inputs.setDragDrop(button);
|
||||
|
||||
button.events.onDragStart.dispatch();
|
||||
expect(x).toBe(0, "drag signal should be disabled");
|
||||
expect(button.inputEnabled).toBe(true, "input should remain enabled");
|
||||
expect(button.input.draggable).toBe(false, "dragging should be disabled at the end");
|
||||
|
||||
testgame.view.inputs.setDragDrop(button, () => x += 1, () => x -= 1);
|
||||
button.events.onDragStart.dispatch();
|
||||
expect(x).toBe(1, "drag signal should be dispatch once");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -137,6 +137,9 @@ module TK.SpaceTac.UI {
|
|||
* If no drag or drop function is defined, dragging is disabled
|
||||
*/
|
||||
setDragDrop(obj: Phaser.Button | Phaser.Image, drag?: Function, drop?: Function): void {
|
||||
obj.events.onDragStart.removeAll();
|
||||
obj.events.onDragStop.removeAll();
|
||||
|
||||
if (drag && drop) {
|
||||
obj.inputEnabled = true;
|
||||
obj.input.enableDrag(false, true);
|
||||
|
|
Loading…
Reference in a new issue