Move button-release-event handling into a new function.