How do you express (Keys.Control | Keys.M) in F #?

In C #, you can express characters for an event KeyPressin a form Keys.Control | Keys.M. In F #, it Keys.Control ||| Keys.Mdoes not work. What is he doing?

Change . Interesting. The use System.Windows.Forms.Keys.Control ||| System.Windows.Forms.Keys.Mas suggested by Johannes Rössel below in the F # interactive window works exactly as it shows. By writing it to the .fs file:

    form.KeyPress.Add (fun e ->
         if (e.KeyChar = (System.Windows.Forms.Keys.Control ||| System.Windows.Forms.Keys.M)) then textbox.SelectAll() )

gives an error The type 'char' does not support any operators named '|||'. Therefore, I probably misidentified the location of the problem. Type from Keysto char does not exist.

+3
source share
2 answers

Use +:

Keys.Control + Keys.M

FWIW |||works for me though:

> System.Windows.Forms.Keys.Control ||| System.Windows.Forms.Keys.M;;
val it : System.Windows.Forms.Keys = M, Control
+2

, ( " " ) .

form.KeyDown
    |> Event.filter (fun e -> e.KeyData = (Keys.Control + Keys.M))
    |> Event.map (fun _ -> textbox.SelectAll())
    |> ignore
+4

Source: https://habr.com/ru/post/1759702/


All Articles