Skip to content

Commit

Permalink
Add Enter KeyBinding and add SearchEnterText to the model.
Browse files Browse the repository at this point in the history
  • Loading branch information
ScottHutchinson committed Sep 26, 2023
1 parent 03af535 commit b5679f5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
6 changes: 5 additions & 1 deletion NG-DART.StructFilters.Views/StructFiltersWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@
Width="200"
Text="{Binding SearchText, UpdateSourceTrigger=PropertyChanged}"
AcceptsReturn="False"
VerticalAlignment="Center"/>
VerticalAlignment="Center">
<TextBox.InputBindings>
<KeyBinding Command="{Binding SearchEnter}" Key="Enter" />
</TextBox.InputBindings>
</TextBox>
</StackPanel>
</Grid>
<TreeView
Expand Down
1 change: 1 addition & 0 deletions NG-DART.StructFilters/Domain.fs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ type Model = {
ExpandLevel: int
MaxLevel: int
Search_Text: string
SearchEnterText: string
}
with
member this.ParentStruct = this.DummyRoot.Fields.Head
Expand Down
8 changes: 7 additions & 1 deletion NG-DART.StructFilters/StructFilters.fs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ module App =
ExpandLevel = 2
MaxLevel = 2
Search_Text = ""
SearchEnterText = ""
}

let mutable configFolderPath = ""
Expand Down Expand Up @@ -116,6 +117,7 @@ module App =
ExpandLevel = unmodifiedModel.ExpandLevel
MaxLevel = unmodifiedModel.MaxLevel
Search_Text = unmodifiedModel.Search_Text
SearchEnterText = ""
}
unmodifiedModel

Expand Down Expand Up @@ -148,6 +150,7 @@ module App =
| CollapseAll
| SetFilteringEnabled of isEnabled: bool
| SearchText of searchText: string
| SearchEnter

let selectAncestorMsg fieldId msg = SelectAncestorMsg (fieldId, msg)
let outSelectChild isGmlSelected msg = OutSelectChild (isGmlSelected, msg)
Expand Down Expand Up @@ -309,6 +312,8 @@ module App =
m
| SearchText searchText ->
{ m with Search_Text = searchText }
| SearchEnter ->
{ m with SearchEnterText = m.Search_Text }

let mapOutMsg = function
| OutSelectChild (isGmlSelected, msg) ->
Expand Down Expand Up @@ -375,7 +380,7 @@ module App =
level < m.ExpandLevel
)
"IsSelected" |> Binding.oneWay(fun ((m: Model), { Self = (s: RoseTree<FieldData>) }) ->
let isSelected = isItemSelected m.Search_Text s.Data
let isSelected = isItemSelected m.SearchEnterText s.Data
if isSelected then
Debug.WriteLine($"****** Name: {s.Data.Name}, Type: {s.Data.Type} selected")
isSelected
Expand Down Expand Up @@ -415,6 +420,7 @@ module App =
(fun m -> m.Search_Text),
(fun newVal _ -> newVal |> SearchText)
)
"SearchEnter" |> Binding.cmd SearchEnter
"IsEnabled" |> Binding.oneWay(fun m -> not m.IsEmpty)
"IsFilteringEnabled" |> Binding.twoWay(
(fun _ -> isFilteringEnabled),
Expand Down

0 comments on commit b5679f5

Please sign in to comment.