Unify inspector and console panel actions
This commit is contained in:
@@ -16,14 +16,11 @@ namespace Editor {
|
||||
HierarchyPanel::HierarchyPanel() : Panel("Hierarchy") {
|
||||
}
|
||||
|
||||
HierarchyPanel::~HierarchyPanel() {
|
||||
if (m_context) {
|
||||
m_context->GetEventBus().Unsubscribe<SelectionChangedEvent>(m_selectionHandlerId);
|
||||
m_context->GetEventBus().Unsubscribe<EntityRenameRequestedEvent>(m_renameRequestHandlerId);
|
||||
}
|
||||
}
|
||||
|
||||
void HierarchyPanel::OnAttach() {
|
||||
if (!m_context || m_selectionHandlerId || m_renameRequestHandlerId) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_selectionHandlerId = m_context->GetEventBus().Subscribe<SelectionChangedEvent>(
|
||||
[this](const SelectionChangedEvent& event) {
|
||||
OnSelectionChanged(event);
|
||||
@@ -36,6 +33,21 @@ void HierarchyPanel::OnAttach() {
|
||||
);
|
||||
}
|
||||
|
||||
void HierarchyPanel::OnDetach() {
|
||||
if (!m_context) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_selectionHandlerId) {
|
||||
m_context->GetEventBus().Unsubscribe<SelectionChangedEvent>(m_selectionHandlerId);
|
||||
m_selectionHandlerId = 0;
|
||||
}
|
||||
if (m_renameRequestHandlerId) {
|
||||
m_context->GetEventBus().Unsubscribe<EntityRenameRequestedEvent>(m_renameRequestHandlerId);
|
||||
m_renameRequestHandlerId = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void HierarchyPanel::OnSelectionChanged(const SelectionChangedEvent& event) {
|
||||
if (m_renameState.IsActive() && event.primarySelection != m_renameState.Item()) {
|
||||
CancelRename();
|
||||
|
||||
Reference in New Issue
Block a user