def on(names, &block)
      [names].flatten.each do |name|
        class_eval do
          # must define this way so block executes in class scope, not static scope
          define_method name, block
        end
      end
    end
def on(names, &block)
      [names].flatten.each do |name|
        class_eval do
          # must define this way so block executes in class scope, not static scope
          define_method name, block
        end
      end
    end
Event Handlers


 call-seq:
   on(callback, ...) { |event_info| block } => Method

 Registers a function of name `name` for a FXML defined event with the body in the block.
 Note you can also just use normal methods

 === Examples
   on :click do
     puts "button clicked"
   end

   on :moved, :pressed do |event|
     puts "Mouse Moved or Key Pressed"
     p event
   end

 === Equivalent Java
   @FXML
   private void click(ActionEvent event) {
     System.out.println("button clicked");
   }

   @FXML
   private void moved(MouseEvent event) {
     System.out.println("Mouse Moved or Key Pressed");
   }

   @FXML
   private void keypress(KeyEvent event) {
     System.out.println("Key Pressed or Key Pressed");
   }