add a function that gets called when the menu item state was changed

This will make it a lot easier to implement menu item states on Linux.
Please note that I only tested this on Linux, so someone needs to verify the windows and mac versions.