Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix clicking on empty part of widget.List not unfocusing #5314

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions internal/driver/glfw/window.go
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ func (w *window) processMouseClicked(button desktop.MouseButton, action action,

co, pos, _ := w.findObjectAtPositionMatching(w.canvas, mousePos, func(object fyne.CanvasObject) bool {
switch object.(type) {
case fyne.Tappable, fyne.SecondaryTappable, fyne.DoubleTappable, fyne.Focusable, desktop.Mouseable:
case fyne.Tappable, fyne.SecondaryTappable, fyne.DoubleTappable, fyne.Focusable, desktop.Mouseable, desktop.Hoverable:
coder-in-go marked this conversation as resolved.
Show resolved Hide resolved
return true
case fyne.Draggable:
if mouseDragStarted {
Expand Down Expand Up @@ -540,9 +540,11 @@ func (w *window) processMouseClicked(button desktop.MouseButton, action action,
if wid, ok := co.(fyne.Focusable); !ok || wid != w.canvas.Focused() {
ignore := false
_, _, _ = w.findObjectAtPositionMatching(w.canvas, mousePos, func(object fyne.CanvasObject) bool {
switch object.(type) {
case fyne.Focusable:
if focusable, isFocusable := object.(fyne.Focusable); isFocusable {
ignore = true
if focusable != w.canvas.Focused() {
w.canvas.Focus(focusable)
coder-in-go marked this conversation as resolved.
Show resolved Hide resolved
}
return true
}

Expand All @@ -568,6 +570,10 @@ func (w *window) processMouseClicked(button desktop.MouseButton, action action,
mousePressed := w.mousePressed
w.mouseLock.Unlock()

if mousePressed == nil {
w.canvas.Unfocus()
}

if action == release && mouseDragged != nil {
if mouseDragStarted {
w.QueueEvent(mouseDragged.DragEnd)
Expand All @@ -593,7 +599,9 @@ func (w *window) processMouseClicked(button desktop.MouseButton, action action,
} else if action == release {
if co == mousePressed {
if button == desktop.MouseButtonSecondary && altTap {
w.QueueEvent(func() { secondary.TappedSecondary(ev) })
w.QueueEvent(func() {
secondary.TappedSecondary(ev)
})
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions widget/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ func (l *List) RefreshItem(id ListItemID) {
return
}
l.BaseWidget.Refresh()

l.Unselect(id)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like an unrelated change? Why are the semantics of RefreshItem changing to that you can't use it to refresh a selected item?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • When the entry is focused, the list item should be unfocused, to unfocus the list item we need this

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But this code is not allowing an item to remain selected when it is refreshed - so scrolling will lose the selected status

lo := l.scroller.Content.(*fyne.Container).Layout.(*listLayout)
lo.renderLock.RLock() // ensures we are not changing visible info in render code during the search
item, ok := lo.searchVisible(lo.visible, id)
Expand Down
Loading