Skip to content

Commit

Permalink
notification event should include actionData (if applicable)
Browse files Browse the repository at this point in the history
  • Loading branch information
ianharrigan committed Jun 3, 2024
1 parent cfab100 commit b6b9c05
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
3 changes: 3 additions & 0 deletions haxe/ui/events/NotificationEvent.hx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package haxe.ui.events;

import haxe.ui.notifications.NotificationData.NotificationActionData;
import haxe.ui.notifications.Notification;

class NotificationEvent extends UIEvent {
Expand All @@ -8,10 +9,12 @@ class NotificationEvent extends UIEvent {
public static final ACTION:EventType<ScrollEvent> = EventType.name("notificationaction");

public var notification:Notification = null;
public var actionData:NotificationActionData = null;

public override function clone():NotificationEvent {
var c:NotificationEvent = new NotificationEvent(this.type);
c.notification = this.notification;
c.actionData = this.actionData;
c.type = this.type;
c.bubble = this.bubble;
c.target = this.target;
Expand Down
23 changes: 13 additions & 10 deletions haxe/ui/notifications/Notification.hx
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,22 @@ class Notification extends VBox {

private function onActionButton(event:MouseEvent) {
var closeNotification = true;
var actionData:NotificationActionData = event.target.userData;

var notificationEvent = new NotificationEvent(NotificationEvent.ACTION);
notificationEvent.notification = this;
dispatch(notificationEvent);
if (notificationEvent.canceled) {
closeNotification = false;
}
NotificationManager.instance.dispatch(notificationEvent, this);
if (notificationEvent.canceled) {
closeNotification = false;
if (actionData.callback == null) {
var notificationEvent = new NotificationEvent(NotificationEvent.ACTION);
notificationEvent.notification = this;
notificationEvent.actionData = actionData;
dispatch(notificationEvent);
if (notificationEvent.canceled) {
closeNotification = false;
}
NotificationManager.instance.dispatch(notificationEvent, this);
if (notificationEvent.canceled) {
closeNotification = false;
}
}

var actionData:NotificationActionData = event.target.userData;
if (actionData.callback != null) {
closeNotification = actionData.callback(actionData);
}
Expand Down

0 comments on commit b6b9c05

Please sign in to comment.