Press in the Activities button when the overlay is entered
In addition to pressing the Activities button, the overlay can be entered by pressing the System key or Alt+F1. We want the button to look pressed in in these cases too.
This commit is contained in:
parent
062e1aa78b
commit
e365a0ba7a
@ -25,15 +25,17 @@ Button.prototype = {
|
|||||||
if (pressedButtonColor == null)
|
if (pressedButtonColor == null)
|
||||||
this._pressedButtonColor = DEFAULT_PRESSED_BUTTON_COLOR;
|
this._pressedButtonColor = DEFAULT_PRESSED_BUTTON_COLOR;
|
||||||
|
|
||||||
|
this._staysPressed = staysPressed
|
||||||
if (staysPressed == null)
|
if (staysPressed == null)
|
||||||
staysPressed = false;
|
this._staysPressed = false;
|
||||||
|
|
||||||
if (minWidth == null)
|
if (minWidth == null)
|
||||||
minWidth = 0;
|
minWidth = 0;
|
||||||
if (minHeight == null)
|
if (minHeight == null)
|
||||||
minHeight = 0;
|
minHeight = 0;
|
||||||
|
|
||||||
// if staysPressed is true, this.active will be true past the first release of a button, untill a subsequent one (the button
|
// if this._staysPressed is true, this._active will be true past the first release of a button, until a subsequent one (the button
|
||||||
// is unpressed) or untill release() is called explicitly
|
// is unpressed) or until release() is called explicitly
|
||||||
this._active = false;
|
this._active = false;
|
||||||
this._isBetweenPressAndRelease = false;
|
this._isBetweenPressAndRelease = false;
|
||||||
this._mouseIsOverButton = false;
|
this._mouseIsOverButton = false;
|
||||||
@ -66,7 +68,7 @@ Button.prototype = {
|
|||||||
this.button.connect('button-release-event',
|
this.button.connect('button-release-event',
|
||||||
function(o, event) {
|
function(o, event) {
|
||||||
me._isBetweenPressAndRelease = false;
|
me._isBetweenPressAndRelease = false;
|
||||||
if (!staysPressed || me._active) {
|
if (!me._staysPressed || me._active) {
|
||||||
me.release();
|
me.release();
|
||||||
} else {
|
} else {
|
||||||
me._active = true;
|
me._active = true;
|
||||||
@ -92,8 +94,15 @@ Button.prototype = {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
pressIn : function() {
|
||||||
|
if (!this._isBetweenPressAndRelease && this._staysPressed) {
|
||||||
|
this._active = true;
|
||||||
|
this.button.backgroundColor = this._pressedButtonColor;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
release : function() {
|
release : function() {
|
||||||
if (!this._isBetweenPressAndRelease) {
|
if (!this._isBetweenPressAndRelease && this._staysPressed) {
|
||||||
this._active = false;
|
this._active = false;
|
||||||
if (this._mouseIsOverButton) {
|
if (this._mouseIsOverButton) {
|
||||||
this.button.backgroundColor = this._buttonColor;
|
this.button.backgroundColor = this._buttonColor;
|
||||||
|
@ -151,6 +151,10 @@ Panel.prototype = {
|
|||||||
// to switch to.
|
// to switch to.
|
||||||
this.button.button.connect('button-press-event',
|
this.button.button.connect('button-press-event',
|
||||||
Lang.bind(Main.overlay, Main.overlay.toggle));
|
Lang.bind(Main.overlay, Main.overlay.toggle));
|
||||||
|
// In addition to pressing the button, the overlay can be entered and exited by other means, such as
|
||||||
|
// pressing the System key, Alt+F1 or Esc. We want the button to be pressed in when the overlay is entered
|
||||||
|
// and to be released when it is exited regardless of how it was triggered.
|
||||||
|
Main.overlay.connect('showing', Lang.bind(this.button, this.button.pressIn));
|
||||||
Main.overlay.connect('hiding', Lang.bind(this.button, this.button.release));
|
Main.overlay.connect('hiding', Lang.bind(this.button, this.button.release));
|
||||||
|
|
||||||
this.actor.add_actor(box);
|
this.actor.add_actor(box);
|
||||||
|
Loading…
Reference in New Issue
Block a user