mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-04 08:46:09 +00:00
Add cancelation support to CloseEvent
This commit is contained in:
parent
e6d0c1858a
commit
05dfd75743
@ -16,7 +16,12 @@ namespace ui {
|
||||
{
|
||||
public:
|
||||
CloseEvent(Component* source)
|
||||
: Event(source) { }
|
||||
: m_canceled(false), Event(source) { }
|
||||
void cancel() { m_canceled = true; }
|
||||
bool canceled() const { return m_canceled; }
|
||||
|
||||
private:
|
||||
bool m_canceled;
|
||||
};
|
||||
|
||||
} // namespace ui
|
||||
|
@ -325,12 +325,16 @@ void Window::openWindowInForeground()
|
||||
|
||||
void Window::closeWindow(Widget* closer)
|
||||
{
|
||||
// Close event
|
||||
CloseEvent ev(closer);
|
||||
onBeforeClose(ev);
|
||||
if (ev.canceled())
|
||||
return;
|
||||
|
||||
m_closer = closer;
|
||||
|
||||
manager()->_closeWindow(this, true);
|
||||
|
||||
// Close event
|
||||
CloseEvent ev(closer);
|
||||
onClose(ev);
|
||||
}
|
||||
|
||||
|
@ -65,6 +65,7 @@ namespace ui {
|
||||
virtual void onSetText() override;
|
||||
|
||||
// New events
|
||||
virtual void onBeforeClose(CloseEvent& ev) {}
|
||||
virtual void onClose(CloseEvent& ev);
|
||||
virtual void onHitTest(HitTestEvent& ev);
|
||||
virtual void onWindowResize();
|
||||
|
Loading…
Reference in New Issue
Block a user