[Ironruby-core] Form Designer adding delegates
Tomas Matousek
Tomas.Matousek at microsoft.com
Wed Oct 24 22:46:44 EDT 2007
1) I think we could support += for events - seems to be quite easy to plug into our infrastructure.
This is a model how I think it could work:
class Form
def initialize
@click = Event.new
end
def click
puts "TRACE: Click"
@click
end
def click=(x)
puts "TRACE: Click=#{x.inspect}"
if x.instance_of? MethodHolder then
@click.add(x.method)
else
@click.set(x)
end
end
end
class MethodHolder
attr :method
def initialize(m)
@method = m
end
end
class Event
def initialize
@methods = []
end
def +(m)
puts "TRACE: +(#{m.inspect}"
MethodHolder.new(m)
end
def call
@methods.each { |m| m.call }
end
def add(m)
@methods << m
end
def set(m)
@methods = [m]
end
end
def bar
puts 'hello'
end
def baz
puts 'world'
end
form = Form.new
form.click += method(:bar)
form.click += method(:baz)
form.click.call
So if you guys don't have objections, I would add it to my TODO list.
Tomas
-----Original Message-----
From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Dermot Hogan
Sent: Wednesday, October 24, 2007 2:47 PM
To: ironruby-core at rubyforge.org
Subject: Re: [Ironruby-core] Form Designer adding delegates
>
>> 1) IronRuby doesn't like the delegate op assign so I can't click on a
>> button
>
> We only support:
>
> self.button1.click do |sender, args|
> # code
> end
>
> today.
>
OK. The Form Designer requires that you add a delegate (at least I think
it does. I haven't found a simple way supporting the above syntax).
Everything else C#, VB, IronPython, etc use the += syntax.
>> 2) I really need 'attr_accessor' to define a 'field' (it's commented
>> out
>> below and I've worked round it, but it's a pain to do). Does it exist
>> yet?
>
> We're working on this - it should be almost doable today.
>
OK. That's good.
>> 3) the references use the full qualified reference name. I can live
>> with
>> this no problem, but it really should use the short form. Is this on
>> the
>> road map?
>
> What I've been doing is assembling these references into a .rb file that
> I require - eg require 'winforms'.
>
I can actually get the fully qualified name from the VS Add References
system, so it's not a problem. It's not urgent by any means - it just
looks odd.
Another minor problem is that I have to use syntax like this:
System::Windows::Forms::Application.EnableVisualStyles()
System::Windows::Forms::Application.SetCompatibleTextRenderingDefault(false);
even with the require 'System::Windows::Forms'
Any way of shortening this?
Also (a more general question) - will IR compile to a PE? I'm assuming
that it runs similarly to MRuby right now (i.e as an interpreter), but I
need to build certain assumptions into the things MSBuild knows about.
If it's going to compile, then I'll make sure MSBuild knows about it.
Don't bend your development plans to accomodate me, btw. I can see that
there's plenty to work on before getting the finer points of the Form
Designer.
Still, I can see impressive progress!
Dermot
--
Posted via http://www.ruby-forum.com/.
_______________________________________________
Ironruby-core mailing list
Ironruby-core at rubyforge.org
http://rubyforge.org/mailman/listinfo/ironruby-core
More information about the Ironruby-core
mailing list