Comments (9)
I would like to be able to have a "right-click" menu on the list item, but also to be able to select the list item and apply logic when the user presses the DELETE key. Is this possible?
from fyne.
I think this is a duplicate of #2551.
We need to re-work the tap handling in the desktop/GLFW driver code to resolve this issue.
from fyne.
I agree. Looks like a duplicate. Let’s close this in favour of the other issue.
from fyne.
I would like to be able to have a "right-click" menu on the list item, but also to be able to select the list item and apply logic when the user presses the DELETE key. Is this possible?
This is possible, if you have your list item implement Tappable and SecondaryTappable. In your Tapped handler, you can just call list.Select(itemID). In your TappedSecondary handler, you show the menu. For the delete key logic, you probably want to extend the List widget itself to provide a replacement for the TypedKey handler that handles DELETE specially, but delegates all other keys to the base List's TypedKey handler.
from fyne.
#2551 mentions assigning a reference to the list and the item ID to the list item in the updateItem() func. That would work for a regular list but I'm using an untyped list and the updateItem() func for that does not pass the ListItemID, but rather the binding.DataItem. Is there no way to reference the ListItemID in this function?
from fyne.
For now I'm simply creating a custom form of NewLisWithData that exposes the ListItemID to the updateItem func.
func NewListWithDataWithID(data binding.DataList, createItem func() fyne.CanvasObject, updateItem func(widget.ListItemID, binding.DataItem, fyne.CanvasObject)) *widget.List {
l := widget.NewList(
data.Length,
createItem,
func(i widget.ListItemID, o fyne.CanvasObject) {
item, err := data.GetItem(i)
if err != nil {
fyne.LogError(fmt.Sprintf("Error getting data item %d", i), err)
return
}
updateItem(i, item, o)
})
data.AddListener(binding.NewDataListener(l.Refresh))
return l
}
from fyne.
So close. I supplied a TypedKey handler to the custom list in order to grab the DELETE keypress as suggested, but it seems that selecting a list item by clicking on it with the mouse does not also set focus to the list so the event is never captured unless I also tab into the list, even after making a selection.
from fyne.
For that last one you can focus it yourself after you call Select, using fyne.CurrentApp().Driver().CanvasForObject(theList).Focus(theList)
from fyne.
This seems more like a discussion, you should consider joining one of our support channels or using GitHub discussions instead of a bug report.
from fyne.
Related Issues (20)
- widget.Scroll doesn't seem to calculate properly the size of its content HOT 2
- When packaging for the web. I get an error when it comes to js packaging HOT 1
- Web target missing multiple window support HOT 4
- Web target missing storage and preferences support HOT 2
- Theme variant broken for `theme.ColorNameHeaderBackground` on Android HOT 1
- macOS: move window to current desktop HOT 2
- Win7 32bit use v2.4.3 can't create window with lower opengl version ( opengl 1.1) HOT 4
- Cause:APIUnavailable: WGL: The driver does rnot appear to support OpenGL HOT 1
- Implement SetDisableScreenBlanking(bool) for desktop
- data races in fyne demo HOT 17
- tests fail with thousands of "Assertion failure in -[NSMenu _lockForMainMenuItemArray], NSMenu.m:1106" HOT 9
- image rendering tests are fragile HOT 3
- High CPU use when showing CustomDialogs HOT 23
- Huge error about openGL and static content HOT 6
- Option to "Share to..." to your Fyne app HOT 1
- Concurent map acces in Table HOT 2
- Callback functions for window resizing HOT 1
- Allow application to set default view (list/grid) of file dialog before showing it HOT 4
- ThemedResource Icons in custom widgets don't follow the overridden theme when inside a themed container
- Add more Objects manipulation functions to Container, and deprecate direct slice access HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fyne.