Skip to content

Commit

Permalink
fix popup menu jittering; fix popup menu single-click vs. double-clic…
Browse files Browse the repository at this point in the history
…k actions
  • Loading branch information
Yatao Li committed Apr 17, 2022
1 parent 7df67f7 commit a79e51e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
13 changes: 12 additions & 1 deletion ViewModels/GridViewModel.fs
Original file line number Diff line number Diff line change
Expand Up @@ -420,10 +420,21 @@ and GridViewModel(_gridid: int, ?_parent: GridViewModel, ?_gridsize: GridSize) a
m_popupmenu_vm.Show <- false

let selectPopupMenuPassive i =
// mark the change as passive
if m_popupmenu_vm.Selection <> i then
m_popupmenu_vm.Passive <- true
m_popupmenu_vm.Selection <- i

let selectPopupMenuActive i =
model.SelectPopupMenuItem i true false
// only changes caused by active selection (not notified from neovim)
// should cause a notification message to be sent back to neovim.
if m_popupmenu_vm.Passive then
#if DEBUG
trace _gridid "selectPopupMenuActive: muting passive change"
#endif
m_popupmenu_vm.Passive <- false
else
model.SelectPopupMenuItem i true false

let commitPopupMenu i =
model.SelectPopupMenuItem i true true
Expand Down
2 changes: 2 additions & 0 deletions ViewModels/PopupMenuViewModel.fs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ type PopupMenuViewModel() =
with get(): bool = m_show
and set(v) = ignore <| this.RaiseAndSetIfChanged(&m_show, v, "Show")

member val Passive: bool = false with get,set

member this.Selection
with get(): int = m_selection
and set(v) = ignore <| this.RaiseAndSetIfChanged(&m_selection, v, "Selection")
Expand Down
3 changes: 3 additions & 0 deletions Views/PopupMenu.xaml.fs
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,6 @@ type PopupMenu() as this =

override this.OnTextInput(e) =
relayToParent e

override this.OnPointerReleased(e) =
e.Handled <- true

0 comments on commit a79e51e

Please sign in to comment.