Skip to content

Commit

Permalink
open / close events for dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
ianharrigan committed Apr 6, 2024
1 parent 9e0af42 commit 753f907
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
12 changes: 12 additions & 0 deletions haxe/ui/components/DropDown.hx
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,9 @@ class DropDownEvents extends ButtonEvents {
private var _wrapper:Box = null;
private var _dropdownOpen:Bool = false;
public function showDropDown() {
if (_dropdownOpen) {
return;
}
var handler:IDropDownHandler = cast(_dropdown._compositeBuilder, DropDownBuilder).handler;
if (handler == null) {
return;
Expand Down Expand Up @@ -834,6 +837,9 @@ class DropDownEvents extends ButtonEvents {
Screen.instance.registerEvent(MouseEvent.RIGHT_MOUSE_DOWN, onScreenMouseDown);
registerEvent(UIEvent.MOVE, onDropDownMoved);
_dropdownOpen = true;

var event = new UIEvent(UIEvent.OPEN);
_dropdown.dispatch(event);
}

private function onDropDownMoved(_) {
Expand Down Expand Up @@ -913,6 +919,9 @@ class DropDownEvents extends ButtonEvents {
}

public function hideDropDown() {
if (!_dropdownOpen) {
return;
}
var handler:IDropDownHandler = cast(_dropdown._compositeBuilder, DropDownBuilder).handler;
if (handler == null) {
return;
Expand All @@ -939,6 +948,9 @@ class DropDownEvents extends ButtonEvents {
Screen.instance.unregisterEvent(MouseEvent.RIGHT_MOUSE_DOWN, onScreenMouseDown);
unregisterEvent(UIEvent.MOVE, onDropDownMoved);
_dropdownOpen = false;

var event = new UIEvent(UIEvent.CLOSE);
_dropdown.dispatch(event);
}

private function onScreenMouseDown(event:MouseEvent) {
Expand Down
5 changes: 4 additions & 1 deletion haxe/ui/events/UIEvent.hx
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,12 @@ class UIEvent extends EventImpl {
/** DISABLED is dispatched when component is disabled **/
public static final DISABLED:EventType<UIEvent> = EventType.name("disabled");

/** OPEN is dispatched by certain components when opened **/
public static final OPEN:EventType<UIEvent> = EventType.name("open");

/** BEFORE_CLOSE is dispatched by tab before closing **/
public static final BEFORE_CLOSE:EventType<UIEvent> = EventType.name("beforeclose");
/** CLOSE is dispatched by tab and menus after closing **/
/** CLOSE is dispatched by certain components when closed **/
public static final CLOSE:EventType<UIEvent> = EventType.name("close");

/** PROPERTY_CHANGE is dispatched by dropdowns, lists, etc where a specific property has changed usually selected item **/
Expand Down

0 comments on commit 753f907

Please sign in to comment.