Giter Club home page Giter Club logo

Comments (9)

BillBuilt avatar BillBuilt commented on May 19, 2024

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.

andydotxyz avatar andydotxyz commented on May 19, 2024

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.

Jacalz avatar Jacalz commented on May 19, 2024

I agree. Looks like a duplicate. Let’s close this in favour of the other issue.

from fyne.

dweymouth avatar dweymouth commented on May 19, 2024

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.

BillBuilt avatar BillBuilt commented on May 19, 2024

#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.

BillBuilt avatar BillBuilt commented on May 19, 2024

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.

BillBuilt avatar BillBuilt commented on May 19, 2024

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.

dweymouth avatar dweymouth commented on May 19, 2024

For that last one you can focus it yourself after you call Select, using fyne.CurrentApp().Driver().CanvasForObject(theList).Focus(theList)

from fyne.

andydotxyz avatar andydotxyz commented on May 19, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.