提交 c2486816 编写于 作者: B Benjamin Pasero

proper checked indicator for context menu actions

上级 1d156ef8
......@@ -200,6 +200,7 @@ export class Separator extends Action {
constructor(label?: string, order?) {
super(Separator.ID, label, label ? 'separator text' : 'separator');
this.checked = false;
this.radio = false;
this.enabled = false;
this.order = order;
}
......@@ -308,6 +309,14 @@ export class ActionItem extends BaseActionItem {
this.$e.removeClass('checked');
}
}
public _updateRadio(): void {
if (this.getAction().radio) {
this.$e.addClass('radio');
} else {
this.$e.removeClass('radio');
}
}
}
export enum ActionsOrientation {
......
......@@ -17,6 +17,7 @@ export interface IAction extends IDisposable {
class: string;
enabled: boolean;
checked: boolean;
radio: boolean;
run(event?: any): TPromise<any>;
}
......@@ -67,6 +68,7 @@ export interface IActionChangeEvent {
class?: string;
enabled?: boolean;
checked?: boolean;
radio?: boolean;
}
export class Action implements IAction {
......@@ -78,6 +80,7 @@ export class Action implements IAction {
protected _cssClass: string;
protected _enabled: boolean;
protected _checked: boolean;
protected _radio: boolean;
protected _order: number;
protected _actionCallback: (event?: any) => TPromise<any>;
......@@ -169,6 +172,14 @@ export class Action implements IAction {
this._setChecked(value);
}
public get radio(): boolean {
return this._radio;
}
public set radio(value: boolean) {
this._setRadio(value);
}
protected _setChecked(value: boolean): void {
if (this._checked !== value) {
this._checked = value;
......@@ -176,6 +187,13 @@ export class Action implements IAction {
}
}
protected _setRadio(value: boolean): void {
if (this._radio !== value) {
this._radio = value;
this._onDidChange.fire({ radio: value });
}
}
public get order(): number {
return this._order;
}
......
......@@ -163,7 +163,7 @@ export class ViewletOverflowActivityActionItem extends BaseActionItem {
const activeViewlet = this.viewletService.getActiveViewlet();
this.actions.forEach(action => {
action.checked = activeViewlet && activeViewlet.getId() === action.id;
action.radio = activeViewlet && activeViewlet.getId() === action.id;
const badge = this.getBadge(action.viewlet);
let suffix: string | number;
......
......@@ -81,8 +81,8 @@ export class ContextMenuService implements IContextMenuService {
const item = new remote.MenuItem({
label: e.label,
checked: !!e.checked,
type: !!e.checked ? 'radio' : void 0,
checked: !!e.checked || !!e.radio,
type: !!e.checked ? 'checkbox' : !!e.radio ? 'radio' : void 0,
accelerator,
enabled: !!e.enabled,
click: (menuItem, win, event) => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册