Refactored button handling in editor