Created
March 29, 2011 21:05
-
-
Save vipenzo/893300 to your computer and use it in GitHub Desktop.
This little program can freeze your PC ... second time you launch it
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tableView(-1, [1], []) | |
2011-03-29 22:53:02.705 macruby[832:903] /Users/penzo/Progetti/faberwork/src/virus.rb:18:in `block': undefined method `delegate=' for 70:Fixnum (NoMethodError) | |
from /Users/penzo/Progetti/faberwork/src/virus.rb:52:in `tableView:writeRows:toPasteboard:' | |
from /Library/Frameworks/MacRuby.framework/Versions/0.9/usr/lib/ruby/Gems/1.9.2/gems/hotcocoa-0.5.1/lib/hotcocoa/mappings/application.rb:10:in `handle_block:' | |
from /Library/Frameworks/MacRuby.framework/Versions/0.9/usr/lib/ruby/Gems/1.9.2/gems/hotcocoa-0.5.1/lib/hotcocoa/mapper.rb:72:in `block' | |
from /Users/penzo/Progetti/faberwork/src/virus.rb:17:in `start' | |
from /Users/penzo/Progetti/faberwork/src/virus.rb:59:in `<main>' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1) Launch the app with macruby | |
# 2) drag a string away from the table | |
# 2a) You get <error.txt> below | |
# 3) close the app | |
# 4) relaunch | |
# 5) drag again | |
# 6) ... hard reboot your pc ... ;) | |
require 'hotcocoa' | |
include HotCocoa | |
class Application | |
include HotCocoa | |
def start | |
@stuff = [ | |
{:name => "Test1"}, | |
{:name => "Test2"}, | |
{:name => "Test3"}, | |
{:name => "Test4"}, | |
{:name => "Test5"}, | |
] | |
application :name => "Virus" do |app| | |
app.delegate = self | |
window :frame => [100, 100, 200, 300], :title => "Virus" do |win| | |
@win = win | |
win << layout_view(:mode => :vertical, :layout => {:expand => [:width, :height]}) do |view| | |
view << scroll_view(:frame => [0, 0, 150, 0], :layout => {:expand => [:height, :width]}) do |scroll| | |
scroll << @table = table_view( | |
:columns => [ | |
column(:id => :name, :title => "stuff"), | |
], | |
:data => self | |
) | |
end | |
end | |
end | |
@win.will_close { exit } | |
@table.registerForDraggedTypes([NSStringPboardType, nil]) | |
@table.edit_table_column? {|col, row| false} | |
end | |
end | |
def numberOfRowsInTableView(tableView) | |
@stuff.length | |
end | |
def tableView(view, objectValueForTableColumn:column, row:i) | |
@stuff[i][column.identifier.intern] | |
end | |
def tableView(view, writeRows: rows, toPasteboard:paste_board) | |
puts "tableView(#{view.selectedRow}, #{rows.inspect}, #{paste_board.pasteboardItems.inspect})" | |
# data = NSArchiver.archivedDataWithRootObject(3) | |
# p data | |
paste_board.declareTypes([NSStringPboardType], owner:nil) | |
paste_board.setData("Foo", forType: NSStringPboardType) | |
true | |
end | |
end | |
Application.new.start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment