Select an item when information button is clicked, launch on single click
Clicking the information button for an item selects it (i.e. highlights it) and shows details about the item. Clicking the rest of the item area launches it. Item does not become draggable if the dragging is started over the information icon (i.e. if the user presses the information icon, but releases elsewhere). Make sure we emit "activated" signal and close the overlay when an item from one of the results displays is launched.
This commit is contained in:
parent
3841e8da74
commit
98c5f35324
@ -63,15 +63,7 @@ GenericDisplayItem.prototype = {
|
|||||||
width: availableWidth,
|
width: availableWidth,
|
||||||
height: ITEM_DISPLAY_HEIGHT });
|
height: ITEM_DISPLAY_HEIGHT });
|
||||||
this.actor._delegate = this;
|
this.actor._delegate = this;
|
||||||
this.actor.connect('button-press-event',
|
this.actor.connect('button-release-event', Lang.bind(this, this.activate));
|
||||||
Lang.bind(this,
|
|
||||||
function(actor, e) {
|
|
||||||
let clickCount = Shell.get_button_event_click_count(e);
|
|
||||||
if (clickCount == 1)
|
|
||||||
this.select();
|
|
||||||
else if (clickCount == 2)
|
|
||||||
this.activate();
|
|
||||||
}));
|
|
||||||
|
|
||||||
let draggable = DND.makeDraggable(this.actor);
|
let draggable = DND.makeDraggable(this.actor);
|
||||||
draggable.connect('drag-begin', Lang.bind(this, this._onDragBegin));
|
draggable.connect('drag-begin', Lang.bind(this, this._onDragBegin));
|
||||||
@ -83,14 +75,23 @@ GenericDisplayItem.prototype = {
|
|||||||
this.actor.add_actor(this._bg);
|
this.actor.add_actor(this._bg);
|
||||||
|
|
||||||
this._informationButton = new Clutter.Texture({ x: availableWidth - ITEM_DISPLAY_PADDING_RIGHT - INFORMATION_BUTTON_SIZE,
|
this._informationButton = new Clutter.Texture({ x: availableWidth - ITEM_DISPLAY_PADDING_RIGHT - INFORMATION_BUTTON_SIZE,
|
||||||
y: ITEM_DISPLAY_HEIGHT / 2 - INFORMATION_BUTTON_SIZE / 2,
|
y: ITEM_DISPLAY_HEIGHT / 2 - INFORMATION_BUTTON_SIZE / 2,
|
||||||
width: INFORMATION_BUTTON_SIZE,
|
width: INFORMATION_BUTTON_SIZE,
|
||||||
height: INFORMATION_BUTTON_SIZE,
|
height: INFORMATION_BUTTON_SIZE,
|
||||||
reactive: true
|
reactive: true
|
||||||
});
|
});
|
||||||
let global = Shell.Global.get();
|
let global = Shell.Global.get();
|
||||||
this._informationButton.set_from_file(global.imagedir + "info.svg");
|
this._informationButton.set_from_file(global.imagedir + "info.svg");
|
||||||
this._informationButton.connect('button-release-event', this.select);
|
// Connecting to the button-press-event for the information button ensures that the actor,
|
||||||
|
// which is a draggable actor, does not get the button-press-event and doesn't initiate
|
||||||
|
// the dragging, which then prevents us from getting the button-release-event for the button.
|
||||||
|
this._informationButton.connect('button-press-event',
|
||||||
|
Lang.bind(this,
|
||||||
|
function() {
|
||||||
|
return true;
|
||||||
|
}));
|
||||||
|
this._informationButton.connect('button-release-event', Lang.bind(this, this.select));
|
||||||
|
|
||||||
this._informationButton.hide();
|
this._informationButton.hide();
|
||||||
this.actor.add_actor(this._informationButton);
|
this.actor.add_actor(this._informationButton);
|
||||||
this._informationButton.lower_bottom();
|
this._informationButton.lower_bottom();
|
||||||
@ -151,14 +152,16 @@ GenericDisplayItem.prototype = {
|
|||||||
this._bg.background_color = color;
|
this._bg.background_color = color;
|
||||||
},
|
},
|
||||||
|
|
||||||
// Activates the item, as though it was launched
|
// Activates the item by launching it
|
||||||
activate: function() {
|
activate: function() {
|
||||||
this.emit('activate');
|
this.emit('activate');
|
||||||
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
// Selects the item, as though it was clicked
|
// Selects the item by highlighting it and displaying it details
|
||||||
select: function() {
|
select: function() {
|
||||||
this.emit('select');
|
this.emit('select');
|
||||||
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -393,6 +393,12 @@ Dash.prototype = {
|
|||||||
this._docDisplay.connect('activated', function(docDisplay) {
|
this._docDisplay.connect('activated', function(docDisplay) {
|
||||||
me.emit('activated');
|
me.emit('activated');
|
||||||
});
|
});
|
||||||
|
this._resultsAppsSection.display.connect('activated', function(resultsAppsDisplay) {
|
||||||
|
me.emit('activated');
|
||||||
|
});
|
||||||
|
this._resultsDocsSection.display.connect('activated', function(resultsDocsDisplay) {
|
||||||
|
me.emit('activated');
|
||||||
|
});
|
||||||
this._appDisplay.connect('selected', function(appDisplay) {
|
this._appDisplay.connect('selected', function(appDisplay) {
|
||||||
// We allow clicking on any item to select it, so if an
|
// We allow clicking on any item to select it, so if an
|
||||||
// item in the app display is selected, we need to make sure that
|
// item in the app display is selected, we need to make sure that
|
||||||
|
Loading…
Reference in New Issue
Block a user