Commit 297beee
committed
Fix Windows menu item state and enabled properties ignored before addItem
On Windows, MenuItem.state and MenuItem.enabled properties set before
the item is added to a Menu via addItem() or insertItem() were silently
ignored. The root cause had two parts:
1. MenuItem::Impl had no enabled_ field - SetEnabled() only called
EnableMenuItem() if parent_menu_ was set (null before addItem),
and IsEnabled() fell back to returning true when parent_menu_ was null.
2. Menu::AddItem() and Menu::InsertItem() hardcoded MF_UNCHECKED for
checkbox/radio types instead of reading the item's current state_,
and never applied MF_GRAYED for disabled items.
Fixes applied:
- Added bool enabled_ field to MenuItem::Impl (default true)
- SetEnabled() always stores to enabled_ regardless of parent_menu_
- IsEnabled() reads from enabled_ field directly
- AddItem() reads item->GetState() for MF_CHECKED/MF_UNCHECKED
- AddItem() checks item->IsEnabled() for MF_GRAYED
- InsertItem() same fixes plus submenu support (was missing entirely)
Resolves libnativeapi/nativeapi-flutter#4
Resolves libnativeapi/nativeapi-flutter#51 parent 00b6fff commit 297beee
2 files changed
Lines changed: 33 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
| 110 | + | |
110 | 111 | | |
111 | 112 | | |
112 | 113 | | |
| |||
123 | 124 | | |
124 | 125 | | |
125 | 126 | | |
| 127 | + | |
126 | 128 | | |
127 | 129 | | |
128 | 130 | | |
| |||
355 | 357 | | |
356 | 358 | | |
357 | 359 | | |
| 360 | + | |
358 | 361 | | |
359 | 362 | | |
360 | 363 | | |
361 | 364 | | |
362 | 365 | | |
363 | 366 | | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | | - | |
370 | | - | |
| 367 | + | |
371 | 368 | | |
372 | 369 | | |
373 | 370 | | |
| |||
575 | 572 | | |
576 | 573 | | |
577 | 574 | | |
578 | | - | |
| 575 | + | |
| 576 | + | |
579 | 577 | | |
580 | | - | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
581 | 584 | | |
582 | 585 | | |
583 | 586 | | |
| |||
611 | 614 | | |
612 | 615 | | |
613 | 616 | | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
614 | 635 | | |
615 | 636 | | |
616 | 637 | | |
617 | 638 | | |
618 | 639 | | |
619 | | - | |
| 640 | + | |
| 641 | + | |
620 | 642 | | |
621 | 643 | | |
622 | 644 | | |
| |||
0 commit comments