git://git.nikiroo.be
/
fanfix.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' of https://github.com/klamonte/jexer
[fanfix.git]
/
src
/
jexer
/
TButton.java
diff --git
a/src/jexer/TButton.java
b/src/jexer/TButton.java
index 24ee94c1abb9c0ff942ddeb90ef1a2c232cc356c..fb8c08e35c4c3a48b6361036837d308c7eb3b9cc 100644
(file)
--- a/
src/jexer/TButton.java
+++ b/
src/jexer/TButton.java
@@
-1,4
+1,4
@@
-/*
*
+/*
* Jexer - Java Text User Interface
*
* License: LGPLv3 or later
* Jexer - Java Text User Interface
*
* License: LGPLv3 or later
@@
-51,6
+51,15
@@
public final class TButton extends TWidget {
*/
private MnemonicString mnemonic;
*/
private MnemonicString mnemonic;
+ /**
+ * Get the mnemonic string for this button.
+ *
+ * @return mnemonic string
+ */
+ public final MnemonicString getMnemonic() {
+ return mnemonic;
+ }
+
/**
* Remember mouse state.
*/
/**
* Remember mouse state.
*/
@@
-66,6
+75,16
@@
public final class TButton extends TWidget {
*/
private TAction action;
*/
private TAction action;
+ /**
+ * Act as though the button was pressed. This is useful for other UI
+ * elements to get the same action as if the user clicked the button.
+ */
+ public void dispatch() {
+ if (action != null) {
+ action.DO();
+ }
+ }
+
/**
* Private constructor.
*
/**
* Private constructor.
*
@@
-136,10
+155,10
@@
public final class TButton extends TWidget {
shadowColor.setForeColor(Color.BLACK);
shadowColor.setBold(false);
shadowColor.setForeColor(Color.BLACK);
shadowColor.setBold(false);
- if (!
get
Enabled()) {
+ if (!
is
Enabled()) {
buttonColor = getTheme().getColor("tbutton.disabled");
menuMnemonicColor = getTheme().getColor("tbutton.disabled");
buttonColor = getTheme().getColor("tbutton.disabled");
menuMnemonicColor = getTheme().getColor("tbutton.disabled");
- } else if (
get
AbsoluteActive()) {
+ } else if (
is
AbsoluteActive()) {
buttonColor = getTheme().getColor("tbutton.active");
menuMnemonicColor = getTheme().getColor("tbutton.mnemonic.highlighted");
} else {
buttonColor = getTheme().getColor("tbutton.active");
menuMnemonicColor = getTheme().getColor("tbutton.mnemonic.highlighted");
} else {
@@
-149,11
+168,11
@@
public final class TButton extends TWidget {
if (inButtonPress) {
getScreen().putCharXY(1, 0, ' ', buttonColor);
if (inButtonPress) {
getScreen().putCharXY(1, 0, ' ', buttonColor);
- getScreen().putStrXY(2, 0, mnemonic.getRawLabel(), buttonColor);
+ getScreen().putStr
ing
XY(2, 0, mnemonic.getRawLabel(), buttonColor);
getScreen().putCharXY(getWidth() - 1, 0, ' ', buttonColor);
} else {
getScreen().putCharXY(0, 0, ' ', buttonColor);
getScreen().putCharXY(getWidth() - 1, 0, ' ', buttonColor);
} else {
getScreen().putCharXY(0, 0, ' ', buttonColor);
- getScreen().putStrXY(1, 0, mnemonic.getRawLabel(), buttonColor);
+ getScreen().putStr
ing
XY(1, 0, mnemonic.getRawLabel(), buttonColor);
getScreen().putCharXY(getWidth() - 2, 0, ' ', buttonColor);
getScreen().putCharXY(getWidth() - 1, 0,
getScreen().putCharXY(getWidth() - 2, 0, ' ', buttonColor);
getScreen().putCharXY(getWidth() - 1, 0,
@@
-182,7
+201,7
@@
public final class TButton extends TWidget {
public void onMouseDown(final TMouseEvent mouse) {
this.mouse = mouse;
public void onMouseDown(final TMouseEvent mouse) {
this.mouse = mouse;
- if ((mouseOnButton()) && (mouse.
get
Mouse1())) {
+ if ((mouseOnButton()) && (mouse.
is
Mouse1())) {
// Begin button press
inButtonPress = true;
}
// Begin button press
inButtonPress = true;
}
@@
-197,7
+216,7
@@
public final class TButton extends TWidget {
public void onMouseUp(final TMouseEvent mouse) {
this.mouse = mouse;
public void onMouseUp(final TMouseEvent mouse) {
this.mouse = mouse;
- if (inButtonPress && mouse.
get
Mouse1()) {
+ if (inButtonPress && mouse.
is
Mouse1()) {
inButtonPress = false;
// Dispatch the event
if (action != null) {
inButtonPress = false;
// Dispatch the event
if (action != null) {