new_editor: deduplicate hosted panel command focus

This commit is contained in:
2026-04-22 18:42:46 +08:00
parent c1e7a0d49f
commit 6efbaf450e
8 changed files with 68 additions and 89 deletions

View File

@@ -1404,31 +1404,6 @@ void ProjectPanel::ResetTransientFrames() {
m_splitterDragging = false;
}
void ProjectPanel::ClaimCommandFocus(
const std::vector<UIInputEvent>& inputEvents,
const UIRect& bounds,
bool allowInteraction) {
if (m_commandFocusService == nullptr) {
return;
}
for (const UIInputEvent& event : inputEvents) {
if (event.type == UIInputEventType::FocusGained) {
m_commandFocusService->ClaimFocus(EditorActionRoute::Project);
return;
}
if (!allowInteraction ||
event.type != UIInputEventType::PointerButtonDown ||
!ContainsPoint(bounds, event.position)) {
continue;
}
m_commandFocusService->ClaimFocus(EditorActionRoute::Project);
return;
}
}
void ProjectPanel::Update(
const UIEditorHostedPanelDispatchEntry& dispatchEntry,
const std::vector<UIInputEvent>& inputEvents) {
@@ -1489,7 +1464,9 @@ void ProjectPanel::Update(
},
dispatchEntry.focusGained,
dispatchEntry.focusLost);
ClaimCommandFocus(
TryClaimHostedPanelCommandFocus(
m_commandFocusService,
EditorActionRoute::Project,
filteredEvents,
dispatchEntry.bounds,
dispatchEntry.allowInteraction);