Sha256: ef210acf0f2546f33bbe343edc5a2c263ef52921b9ea09345510debceada5470

Contents?: true

Size: 817 Bytes

Versions: 3

Compression:

Stored size: 817 Bytes

Contents

require 'mouse'


class MouseDraw
  
  def self.go
  
  require 'java'

  java_import 'javax.swing.JFrame'
  java_import 'javax.swing.JButton'
  java_import 'com.sun.awt.AWTUtilities'

  f = JFrame.new
  f.add JButton.new('capture window')
  f.set_size(200,200)

  AWTUtilities.set_window_opacity(f, 0.5)
  
  # wait till mouse goes down...
  while(Mouse.left_mouse_button_state == :up)
    sleep 0.05
    print 'waiting'
  end
  f.undecorated = true
  f.default_close_operation = JFrame::EXIT_ON_CLOSE
  f.always_on_top = true
  f.visible = true
  f.set_location(Mouse.get_mouse_location)
  while(Mouse.left_mouse_button_state == :down)
    # set_size
    p 'waiting for end'
    p Mouse.get_mouse_location
  end
  f.dispose
end
  
end


if $0 == __FILE__
  MouseDraw.go
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sensible-cinema-0.26.1 lib/mouse_draw.rb
sensible-cinema-0.26.0 lib/mouse_draw.rb
sensible-cinema-0.25.4 lib/mouse_draw.rb