From 65c5186a20fe6db69a18d9231001126e44a0e266 Mon Sep 17 00:00:00 2001 From: Sam Whited Date: Fri, 3 Aug 2018 13:02:59 -0500 Subject: [PATCH] Call modal done func on escape key Fixes #150 --- modal.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modal.go b/modal.go index 8ed535e..9ef7e38 100644 --- a/modal.go +++ b/modal.go @@ -40,6 +40,11 @@ func NewModal() *Modal { SetButtonBackgroundColor(Styles.PrimitiveBackgroundColor). SetButtonTextColor(Styles.PrimaryTextColor) m.form.SetBackgroundColor(Styles.ContrastBackgroundColor).SetBorderPadding(0, 0, 0, 0) + m.form.SetCancelFunc(func() { + if m.done != nil { + m.done(-1, "") + } + }) m.frame = NewFrame(m.form).SetBorders(0, 0, 1, 0, 0, 0) m.frame.SetBorder(true). SetBackgroundColor(Styles.ContrastBackgroundColor).