The parser binds "then expr" over the whole preceeding expr (let-expr), rather than the immediately preceeding object expression. I've logged the bug. Thanks.

By on 9/27/2006 4:13 AM ()

Yes, this is currently a bit of a pain - trigger is not in scope ("let" binds more tightly than "then", and the syntactic forms permitted for constructors are very limited due to .NET rules) .

You might prefer to have a hidden constructor and a static "Create" method, which is in general more flexible.

1
2
3
4
5
6
7
8
9
10
11
12
13
type LeftClickForm = class
    inherit Form
    val LeftMouseClick : Idioms.IEvent<MouseEventArgs>
    new(leftMouseClickEvent) = {LeftMouseClick = leftMouseClickEvent}
    static member Create() =
        let trigger, event = IEvent.create()
        let x = new LeftClickForm(event) 
        x.MouseClick
          |> IEvent.filter (fun e -> e.Button = MouseButtons.Left) 
          |> IEvent.listen (fun e -> trigger e);
        x
        
end

Notes:

Don

By on 9/27/2006 4:12 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper