#!ruby # -*- mode: ruby; coding: utf-8 -*- # Last updated: <2016/01/11 22:11:32 +0900> require_relative './lib/dxrubyws' module WS class DraggableTofu < WSControl include Draggable def initialize(x, y, width, height) super self.image = Image.new(width, height, C_WHITE) self.add_handler(:drag_move, self.method(:on_drag_move)) end # def on_drag_move(obj, dx, dy) def on_drag_move(dx, dy) self.x += dx self.y += dy end end end tofu = WS::DraggableTofu.new(200, 100, 100, 100) WS.desktop.add_control(tofu) Window.loop do WS.update end