1 package Reaction::UI::ViewPort::Action::Role::Close;
4 use MooseX::Types::Moose qw/Str CodeRef/;
5 with 'Reaction::UI::ViewPort::Action::Role::Apply';
7 has close_label => (is => 'rw', isa => Str, lazy_build => 1);
8 has on_close_callback => (is => 'rw', isa => CodeRef);
9 has close_label_close => (is => 'rw', isa => Str, lazy_build => 1);
10 has close_label_cancel => (is => 'rw', isa => Str, lazy_build => 1);
12 sub _build_close_label { shift->_build_close_label_close }
13 sub _build_close_label_close { 'close' }
14 sub _build_close_label_cancel { 'cancel' }
20 return unless $self->has_on_close_callback;
21 $self->on_close_callback->($self);
27 my $success = $self->$orig(@_);
28 $self->close_label( $self->close_label_cancel ) unless $success;
32 # can't do a close-type operation if there's nowhere to go afterwards
33 around accept_events => sub {
36 ( ($self->has_on_close_callback ? ('close') : ()), $self->$orig(@_) );
45 Reaction::UI::ViewPort::Action::Role::Close
51 Default: C<close_label_close>
53 =head2 close_label_close
57 =head2 close_label_cancel
59 This label is only shown when C<changed> is true.
63 =head2 on_close_callback
75 L<Reaction::UI::ViewPort::Action::Role::Apply>
77 L<Reaction::UI::ViewPort::Action::Role::OK>
81 See L<Reaction::Class> for authors.
85 See L<Reaction::Class> for the license.