Add tree navigation via arrow keys
This commit is contained in:
@@ -3,22 +3,37 @@ import { EventDispatcher } from '../../../events'
|
||||
|
||||
export class TopicViewModel implements Destroyable {
|
||||
private selected: boolean
|
||||
public change = new EventDispatcher<void, TopicViewModel>()
|
||||
private expanded: boolean
|
||||
public selectionChange = new EventDispatcher<void, TopicViewModel>()
|
||||
public expandedChange = new EventDispatcher<void, TopicViewModel>()
|
||||
|
||||
public constructor() {
|
||||
this.selected = false
|
||||
this.expanded = false
|
||||
}
|
||||
|
||||
public destroy() {
|
||||
this.change.removeAllListeners()
|
||||
this.selectionChange.removeAllListeners()
|
||||
}
|
||||
|
||||
public isSelected() {
|
||||
return this.selected
|
||||
}
|
||||
|
||||
public isExpanded() {
|
||||
return this.expanded
|
||||
}
|
||||
|
||||
public setSelected(selected: boolean) {
|
||||
this.selected = selected
|
||||
this.change.dispatch()
|
||||
this.selectionChange.dispatch()
|
||||
}
|
||||
|
||||
public setExpanded(expanded: boolean, fireEvent: boolean) {
|
||||
const didChange = this.expanded !== expanded
|
||||
this.expanded = expanded
|
||||
if (didChange && fireEvent) {
|
||||
this.expandedChange.dispatch()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user