-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathControls.fs
More file actions
31 lines (27 loc) · 878 Bytes
/
Controls.fs
File metadata and controls
31 lines (27 loc) · 878 Bytes
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
namespace NDLC.GUI
open System
open Avalonia.Controls
open Avalonia.FuncUI.DSL
open Avalonia.Input
open Avalonia.Interactivity
module TextBox =
let onTextInput handler =
let handler' (args: RoutedEventArgs) =
let tx = (args.Source :?> TextBox).Text
if String.IsNullOrEmpty tx then () else
handler tx
[
TextBox.onKeyDown(handler')
TextBox.onKeyUp(handler')
]
let onTextInputFinished handler =
let handler' =
fun (args: KeyEventArgs) ->
if args.Key = Key.Enter || args.Key = Key.Tab then
let tx = (args.Source :?> TextBox).Text
if String.IsNullOrEmpty tx then () else
handler tx
[
TextBox.onKeyDown(handler')
TextBox.onKeyUp(handler')
]