LVRS Document Viewer
components/navigation/MenuItem.svx
Path: components/navigation/MenuItem.svx
MenuItem
Location: /Users/ymy/Developer/LVRS/qml/components/navigation/MenuItem.qml
MenuItem is a context-menu row component with icon, label, shortcut, state styling, and chevron direction control.
Purpose
- Render one context-menu action row with compact spacing.
- Support icon/text binding and key/shortcut binding.
- Expose submenu selection direction through a simple input API.
API
State:
defaultStateselectedStateinactiveStatestate
Content:
labelkey/shortcuticonNameiconSource
Chevron:
showChevronselectionDirection(supportsright|left|up|downstring or numeric enum)- direction enum constants:
directionRightdirectionLeftdirectionUpdirectionDown
Layout:
itemWidth(default:161)itemHeight(default:22)iconSize(default:16)chevronSize(default:16)
Usage
import LVRS 1.0 as LV
LV.MenuItem {
iconName: "projectStructure"
label: "Open Recent"
key: "Cmd+O"
showChevron: true
selectionDirection: "right"
state: defaultState
}
How It Works
- Background is resolved from
state:- default: transparent
- selected:
Theme.contextMenuItemSelectedBackground - inactive:
Theme.panelBackground08
- Icon source resolution order:
iconSourceiconNameviaTheme.iconPath(...)- placeholder block
- Chevron path is painted on
Canvasand rotates by resolved direction.
Practical Notes
- Use
selectionDirectionto bind submenu opening side from runtime data. - Keep label/key strings concise to preserve menu rhythm.
- If a row is final action (no submenu), set
showChevron: false.
Validation Checklist
- row size matches
161x22contract, - selected and inactive colors render correctly,
- chevron direction follows
selectionDirection, - icon and text bindings update without manual refresh.