WinForms

From $1

Table of contents
  1. 1. Events

TODO: This page has minimal content. Enrich IronRuby by contributing.

Events

System.Windows.Forms.Form needs an IronRuby subclass that inherits from it. This is to allow attaching methods to the events that are declared protected.

>>> require "System.Windows.Forms"
=> true
>>> include System::Windows::Forms
=> Object
>>> class RForm < Form
>>> end
=> nil
>>> f = RForm.new
=> IronRuby.Classes.Form$1, Text:

Setup the procs to be called and bind to names so we can add and remove them from the events later.

>>> ome = proc {|sender, e| puts "Enter"}
=> #(Proc:0x0@)
>>> oml = proc {|sender, e| puts "Leave"}
=> #(Proc:0x1@)
>>> f.mouse_enter(&ome)
=> #(Proc:0x0@)
>>> f.mouse_leave(&oml)
=> #(Proc:0x1@)

Setup the message pump to start the form and watch the action.

>>> Application.run(f)

This will setup the the on_mouse_enter and on_mouse_leave events to be called, show the form, display text out on the console when events fire.

Note: Do all the declaration first as the message pump handling is a blocking operation.

 
Images (0)
 
Comments (0)
You must login to post a comment.

 
SourceForge.net