Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Perform an action after an entry's button is pressed in SwiftEntryKit

Tags:

swift

I have added 2 buttons to my SwiftEntryKit popup but cannot figure out how to do something after a button is pressed.

I follow the pattern set with their example for alerts.

I tried entering something into the dismiss action, but it did not work:

// Ok Button
let okButtonLabelStyle = EKProperty.LabelStyle(font: buttonFont, color: buttonColor)
let okButtonLabel = EKProperty.LabelContent(text: "OK, ACCEPT", style: okButtonLabelStyle)
let okButton = EKProperty.ButtonContent(label: okButtonLabel, backgroundColor: .clear, highlightedBackgroundColor:  buttonColor.withAlphaComponent(0.05)) {
    SwiftEntryKit.dismiss {
        print("okButton")
    }

}

Thank you.

like image 448
diogenes Avatar asked Dec 02 '25 14:12

diogenes


1 Answers

You have to set entryInteraction to .absorbTouches for the attributes property of SwiftEntryKit.display.

var attributes = EKAttributes()
attributes.entryInteraction = .absorbTouches

[...]

SwiftEntryKit.display(entry: <entry variable>, using: attributes)
like image 175
Tamás Sengel Avatar answered Dec 05 '25 05:12

Tamás Sengel