NAME

Term::Fabulous::Event::SortChange - The user changed how a table is sorted

SYNOPSIS

$table->on( SortChange => sub ($event) {
	my @keys = map { "$_->[0] ($_->[1])" } @{ $event->sort };
	$status->text( @keys ? "sorted by @keys" : 'unsorted' );
	return;
} );

DESCRIPTION

Term::Fabulous::Widget::Table fires SortChange on itself when the user sorts it by a sortable column: a click on the column's header (with Shift, Ctrl or Alt it adds the column to the sort), or Enter or Space on the header in header mode (see "KEYS" in Term::Fabulous::Widget::Table). Each of these cycles the column from ascending to descending to unsorted. A column with sortable => 0 ignores them and fires nothing. Sorting from your program ("sort_by" in Term::Fabulous::Widget::Table, clear_sort) fires nothing. Sorting is explained in "SORTING" in Term::Fabulous::Manual::TableRows.

It is a Clay::UI::Events::Event whose name is SortChange; listen for it with $table->on( SortChange => sub ($event) { ... } ). It bubbles to the table's ancestors like every event (see "Return values and bubbling" in Term::Fabulous::Manual::Events), and $event->target is the table.

CONSTRUCTOR

new

my $event = Term::Fabulous::Event::SortChange->new( sort => ... );

The table builds these events itself; build one yourself only to test your listeners. Unknown parameters die, and so does a sort that is not an array reference of array references; it is copied.

sort

See "sort".

METHODS

sort

The new sort: a new array reference of [ $column_key, 'asc' or 'desc' ] pairs, the first one sorting first; empty when the table is unsorted.

SEE ALSO

Term::Fabulous::Widget::Table, "EVENTS" in Term::Fabulous::Manual::Events, "Sort rows, also with your own comparison" in Term::Fabulous::Cookbook::TableRows.