issue #5685: fix a bug of MenuItemToggle that callback is not correctly initialized when using new
Merge pull request #1972 from joshuastray/use_new_in_sample

issue #5685: fix a bug of MenuItemToggle that callback is not correctly initialized when using new