Skip to content

Commit

Permalink
resumePanelEvents one frame later
Browse files Browse the repository at this point in the history
  • Loading branch information
ianharrigan committed Aug 8, 2023
1 parent d704b59 commit 68cabb6
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions haxe/ui/components/pickers/ItemPicker.hx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class ItemPickerHandler {
public var builder:ItemPickerBuilder;
public var picker:ItemPicker;
public var renderer:Component;
public var panel:Component;
public var panel:Component;

private function pausePanelEvents() {
builder.pausePanelEvents();
Expand All @@ -85,7 +85,7 @@ class ItemPickerHandler {
private class DefaultItemPickerRenderer extends HBox {
private var _renderer:ItemRenderer = new BasicItemRenderer();
private var _triggerIcon:Image = new Image();

public function new() {
super();

Expand Down Expand Up @@ -209,7 +209,9 @@ class ItemPickerBuilder extends CompositeBuilder {

public function resumePanelEvents() {
if (panel != null) {
panel.resumeEvent(panelSelectionEvent);
Toolkit.callLater(function() {
panel.resumeEvent(panelSelectionEvent);
});
}
}

Expand All @@ -228,7 +230,7 @@ class ItemPickerBuilder extends CompositeBuilder {
//event.cancel();
if (!_panelVisible) {
picker.focus = true;
showPanel();
showPanel();
} else {
hidePanel();
}
Expand Down Expand Up @@ -258,7 +260,7 @@ class ItemPickerBuilder extends CompositeBuilder {
});

positionPanel();

if (picker.animatable) {
panelContainer.fadeIn();
} else {
Expand All @@ -267,9 +269,7 @@ class ItemPickerBuilder extends CompositeBuilder {
Screen.instance.registerEvent(MouseEvent.MOUSE_DOWN, onScreenMouseDown);
_panelVisible = true;

Toolkit.callLater(function() {
resumePanelEvents();
});
resumePanelEvents();
}

private function positionPanel() {
Expand All @@ -279,33 +279,33 @@ class ItemPickerBuilder extends CompositeBuilder {
var panelOrigin = picker.panelOrigin;
var panelWidth:Null<Float> = picker.width;
var panelHeight:Null<Float> = panel.height;

if (picker.panelWidth != null) {
panelWidth = picker.panelWidth;
}

if (panelPosition == "auto") {
if (picker.screenTop + picker.height + panelHeight > Screen.instance.height) {
panelPosition = "up";
} else {
panelPosition = "down";
}
}

if (panelOrigin == "auto") {
if (picker.screenLeft + panelWidth > Screen.instance.width) {
panelOrigin = "right";
} else {
panelOrigin = "left";
}
}

if (panelPosition == "down") {
panelContainer.addClass("position-down");
} else if (panelPosition == "up") {
panelContainer.addClass("position-up");
}

panelContainer.syncComponentValidation();
panel.validateNow();
panelContainer.validateNow();
Expand All @@ -325,31 +325,31 @@ class ItemPickerBuilder extends CompositeBuilder {
horizontalPadding = panelContainer.style.paddingLeft + panelContainer.style.paddingRight;
borderSize = panelContainer.style.borderTopSize;
}

if (_panelFiller == null) {
_panelFiller = new Component();
_panelFiller.addClass("item-picker-panel-filler");
_panelFiller.includeInLayout = false;
_panelFiller.height = borderSize;
panelContainer.addComponent(_panelFiller);
}

_panelFiller.width = panelWidth - picker.width;
if (_panelFiller.width > 0) {
_panelFiller.show();
} else {
_panelFiller.hide();
}
panel.width = panelWidth - horizontalPadding;

if (panelOrigin == "left") {
panelContainer.left = picker.screenLeft;
_panelFiller.left = picker.width - borderSize;
} else if (panelOrigin == "right") {
panelContainer.left = picker.screenLeft + picker.width - panelWidth;
_panelFiller.left = borderSize;
}

if (panelPosition == "down") {
panelContainer.top = picker.screenTop + picker.height + marginTop;
_panelFiller.top = 0;
Expand All @@ -361,7 +361,7 @@ class ItemPickerBuilder extends CompositeBuilder {

public function hidePanel() {
picker.isPanelOpen = false;

if (picker.animatable) {
/*
panelContainer.fadeOut(function() {
Expand Down

0 comments on commit 68cabb6

Please sign in to comment.