Your latest code worked. However, the custom menu is displaying at the center of the card when I click (left click) on the custom Icon found on the upper right of the card. Right click is working, I can right click anywhere in the card and the default menu is showing just beside the mouse pointer.
Update: I tried to remove the body items (made them hidden) and just left the custom header visible (header text and custom icon). When I clicked on the custom I con, the custom menu is working as expected.
When all of the items in the card are displayed then I clicked on the custom icon at the upper right, the Task Menu is displayed at the center of the card which not correct. It should pop out just beside the mouse pointer.