ClipboardEvent seems to be highly experimental and not all major browsers implement it fully or even partially as I can see. probably taht is the reason why it was not incorporated in the core JavaScript bindings. With that said you can easily create your own extension though. The following is the basic definition in WIG (an Extension project):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
open IntelliFactory.WebSharper
open IntelliFactory.WebSharper.InterfaceGenerator

module Definition =

    let ClipboardEventType =
        Pattern.EnumStrings "ClipboardEventType" [ "copy"; "cut"; "paste" ]

    let DataTransfer =
        Class "DataTransfer"
        |+> Instance [
            "dropEffect" =@ T<string>
            "effectAllowed" =@ T<string>
        ]

    let ClipboardEventConfig =
        Pattern.Config "ClipboardEventConfig"
            {
                Optional = []
                Required = 
                    [
                        "dataType", T<string>
                        "data", T<string>
                    ]
            }

    let ClipboardEvent =
        Class "ClipboardEvent"
        |=> Inherits T<JavaScript.Dom.Event>
        |+> Instance [
            "clipboardData" =? DataTransfer
        ]
        |+> Static [
            Constructor (ClipboardEventType?``type`` * ClipboardEventConfig?config)
        ]

    let Assembly =
        Assembly [
            Namespace "IntelliFactory.WebSharper.JavaScript" [
                ClipboardEventType
                DataTransfer
                ClipboardEventConfig
                ClipboardEvent
            ]
        ]

You might want to take a look at the WIG docs and our little intro tutorial to WIG. Please note that some documentation may be slightly outdated as we are currently changing a lot of things up in the alpha versions. You can find the changes spread across multiple blogposts in our blog.

Alternatively check out the manual bindings guide. I personally would recommend not using this over WIG but you like it more nobody's stopping you.

Hope this is enough to get you started.

By on 2/23/2015 7:07 AM ()

Thanks, I suspected that I needed WIG, I just lacked the knowledge how to.

By on 2/24/2015 3:07 AM ()

I just tried the above in a newly created Websharper Extension project.

Three times I get the error "The type 'CodeModel.IClassMember list' is not compatible with the type 'CodeModel.Member'"

Twice on both "|+> Instance", and once on "|+> Static"

Version problem?

By on 2/24/2015 3:17 AM ()

It might be version issues -- we have changed the API quite a bit in the last few weeks -- but it might just be some namespace clashing issue (honestly the template is not very up-to-date). I have created a gist with the whole file. This should compile so check it out.

By on 2/24/2015 3:30 AM ()

Hi, got this working now in version 3.0.46.130-rc1. It works in FF, Chrome, but not in IE.

I understand that if you want to paste from the clipboard in IE, you need to acces "Window.clipboardData" (see: https://msdn.microsoft.com/en-us/library/ie/ms535220%28v=vs.85%29.aspx, other sources exist).

Is there a way to extend the existing "Window" object in WebSharper.JavaScript.Window?

By on 4/4/2015 9:18 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