修复二级菜单移向途中被误关闭;新增项目记忆文档 agent_mem.md
网格右键菜单「实验性功能」展开二级菜单后,鼠标从父项移向子菜单途中经过内边距窄带会被立即收起。改为子菜单展开期间只要指针仍在主菜单∪子菜单范围内且未落到其它可点击条目即保持展开并高亮父项。
This commit is contained in:
1 parent
7608e85cf0
commit
2322e76d8c
2 files changed
+189
-4
No files matched your search
@@ -678,10 +678,12 @@ namespace jdi
|
||||
return false;
|
||||
}
|
||||
|
||||
const float fx = static_cast<float>(x);
|
||||
const float fy = static_cast<float>(y);
|
||||
bool changed = false;
|
||||
|
||||
// 鼠标在展开的子菜单内:只更新子菜单的悬停项(主菜单父项保持高亮)。
|
||||
if (m_subOpen && UiPointInRect(m_subRect, static_cast<float>(x), static_cast<float>(y)))
|
||||
if (m_subOpen && UiPointInRect(m_subRect, fx, fy))
|
||||
{
|
||||
const int sub = SubItemAtPoint(x, y);
|
||||
if (sub != m_subHoverIndex)
|
||||
@@ -694,6 +696,25 @@ namespace jdi
|
||||
|
||||
int swatchIndex = -1;
|
||||
const int index = ItemAtPoint(x, y, swatchIndex);
|
||||
const bool onSubmenuParent =
|
||||
(index >= 0) && (m_items[static_cast<std::size_t>(index)].kind == MenuItemKind::SUBMENU);
|
||||
|
||||
// 子菜单展开期间,鼠标只要仍停留在「主菜单 ∪ 子菜单」的范围内且尚未落到其它可点击
|
||||
// 条目上(例如掠过父项右缘与子菜单之间的内边距窄带、分隔线或禁用项),就不收起子菜单。
|
||||
// 这样可避免处理器速度较快、鼠标移动事件过密时,用户还没把指针移到子菜单上,
|
||||
// 子菜单就被中途误关闭;只有明确移到其它条目或完全离开该范围时才收起。
|
||||
if (m_subOpen && !onSubmenuParent && index < 0 &&
|
||||
(UiPointInRect(m_rect, fx, fy) || UiPointInRect(m_subRect, fx, fy)))
|
||||
{
|
||||
// 保持在父项高亮,视觉上指明子菜单的来源。
|
||||
if (m_hoverIndex != m_subParentIndex || m_hoverSwatch != -1)
|
||||
{
|
||||
m_hoverIndex = m_subParentIndex;
|
||||
m_hoverSwatch = -1;
|
||||
changed = true;
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
if (index != m_hoverIndex || swatchIndex != m_hoverSwatch)
|
||||
{
|
||||
@@ -702,9 +723,7 @@ namespace jdi
|
||||
changed = true;
|
||||
}
|
||||
|
||||
// 悬停到带子菜单的项 → 向右展开;移开到其它条目 → 收起。
|
||||
const bool onSubmenuParent =
|
||||
(index >= 0) && (m_items[static_cast<std::size_t>(index)].kind == MenuItemKind::SUBMENU);
|
||||
// 悬停到带子菜单的项 → 向右展开;移开到其它条目或离开菜单 → 收起。
|
||||
if (onSubmenuParent)
|
||||
{
|
||||
if (!m_subOpen || m_subParentIndex != index)
|
||||
|
||||
Reference in new issue
Block a user