@@ -703,59 +703,69 @@ - (void)menuDidClose:(NSMenu*)menu {
703703 double menu_height = menu_size.height ;
704704
705705 // Adjust position based on placement
706+ // Note: Coordinates are in top-left origin system (y grows downward)
707+ // popUpMenuPositioningItem places the menu's top-left corner at the specified location
706708 switch (placement) {
707- case Placement::TopStart: // topLeft
708- x -= menu_width;
709- y += menu_height;
709+ case Placement::TopStart: // Menu above reference point, left-aligned
710+ // Menu's bottom-left corner at reference point
711+ // No x adjustment needed (left-aligned)
712+ // Move up by menu height
713+ y -= menu_height;
710714 break ;
711715
712- case Placement::Top: // top center
716+ case Placement::Top: // Menu above reference point, center-aligned
717+ // Menu's bottom-center at reference point
713718 x -= menu_width / 2.0 ;
714- y + = menu_height;
719+ y - = menu_height;
715720 break ;
716721
717- case Placement::TopEnd: // topRight
718- y += menu_height;
722+ case Placement::TopEnd: // Menu above reference point, right-aligned
723+ // Menu's bottom-right corner at reference point
724+ x -= menu_width;
725+ y -= menu_height;
719726 break ;
720727
721- case Placement::RightStart: // right top
722- x += menu_width;
723- y += menu_height;
728+ case Placement::RightStart: // Menu to the right, top-aligned
729+ // Menu's top-left corner at reference point (no adjustment needed)
724730 break ;
725731
726- case Placement::Right: // right center
727- x += menu_width;
732+ case Placement::Right: // Menu to the right, center-aligned
733+ // Menu's left-center at reference point
728734 y -= menu_height / 2.0 ;
729735 break ;
730736
731- case Placement::RightEnd: // right bottom
732- x += menu_width;
737+ case Placement::RightEnd: // Menu to the right, bottom-aligned
738+ // Menu's bottom-left corner at reference point
733739 y -= menu_height;
734740 break ;
735741
736- case Placement::BottomStart: // bottomLeft
737- x -= menu_width;
742+ case Placement::BottomStart: // Menu below reference point, left-aligned
743+ // Menu's top-left corner at reference point (no adjustment needed)
738744 break ;
739745
740- case Placement::Bottom: // bottom center
746+ case Placement::Bottom: // Menu below reference point, center-aligned
747+ // Menu's top-center at reference point
741748 x -= menu_width / 2.0 ;
742749 break ;
743750
744- case Placement::BottomEnd: // bottomRight
745- // No adjustment needed
751+ case Placement::BottomEnd: // Menu below reference point, right-aligned
752+ // Menu's top-right corner at reference point
753+ x -= menu_width;
746754 break ;
747755
748- case Placement::LeftStart: // left top
756+ case Placement::LeftStart: // Menu to the left, top-aligned
757+ // Menu's top-right corner at reference point
749758 x -= menu_width;
750- y += menu_height;
751759 break ;
752760
753- case Placement::Left: // left center
761+ case Placement::Left: // Menu to the left, center-aligned
762+ // Menu's right-center at reference point
754763 x -= menu_width;
755764 y -= menu_height / 2.0 ;
756765 break ;
757766
758- case Placement::LeftEnd: // left bottom
767+ case Placement::LeftEnd: // Menu to the left, bottom-aligned
768+ // Menu's bottom-right corner at reference point
759769 x -= menu_width;
760770 y -= menu_height;
761771 break ;
0 commit comments