immutable TKeypressEvent
[fanfix.git] / src / jexer / event / TCommandEvent.java
CommitLineData
df8de03f
KL
1/**
2 * Jexer - Java Text User Interface
3 *
df8de03f
KL
4 * License: LGPLv3 or later
5 *
7b5261bc
KL
6 * This module is licensed under the GNU Lesser General Public License
7 * Version 3. Please see the file "COPYING" in this directory for more
8 * information about the GNU Lesser General Public License Version 3.
df8de03f
KL
9 *
10 * Copyright (C) 2015 Kevin Lamonte
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Lesser General Public License
14 * as published by the Free Software Foundation; either version 3 of
15 * the License, or (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this program; if not, see
24 * http://www.gnu.org/licenses/, or write to the Free Software
25 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
26 * 02110-1301 USA
7b5261bc
KL
27 *
28 * @author Kevin Lamonte [kevin.lamonte@gmail.com]
29 * @version 1
df8de03f
KL
30 */
31package jexer.event;
32
33import jexer.TCommand;
34
35/**
7b5261bc
KL
36 * This class encapsulates a user command event. User commands can be
37 * generated by menu actions, keyboard accelerators, and other UI elements.
38 * Commands can operate on both the application and individual widgets.
df8de03f 39 */
b299e69c 40public final class TCommandEvent extends TInputEvent {
df8de03f
KL
41
42 /**
7b5261bc
KL
43 * Command dispatched.
44 */
45 private TCommand cmd;
46
47 /**
48 * Get TCommand.
49 *
50 * @return the TCommand
df8de03f 51 */
b299e69c 52 public TCommand getCmd() {
7b5261bc
KL
53 return cmd;
54 }
df8de03f
KL
55
56 /**
7b5261bc 57 * Public contructor.
df8de03f
KL
58 *
59 * @param cmd the TCommand dispatched
60 */
7b5261bc
KL
61 public TCommandEvent(final TCommand cmd) {
62 this.cmd = cmd;
df8de03f
KL
63 }
64
65 /**
7b5261bc
KL
66 * Make human-readable description of this TCommandEvent.
67 *
68 * @return displayable String
df8de03f
KL
69 */
70 @Override
b299e69c 71 public String toString() {
7b5261bc 72 return String.format("CommandEvent: %s", cmd.toString());
df8de03f
KL
73 }
74}