I am very happy with having the text fields working in the listbox in my app, but now… I would like to take it a step further and replace the 2nd cell text field with a popup menu, so the user can simply choose what he needs from a list, instead of filling it in all the time. Is this possible?
In the properties of a cell I only see these options, but maybe e there is a work around?
no popup exactly here, but a good start…
warning: it is API1
Thanks, I will have a look. I hope this Type will be added to the desktopListbox soon.
there is also this one with a combobox
You can also do it yourself with using a DesktopMenuItem (which you fill with various sub items) and use the Popup method to show it.
The following Code placed in the MouseDown Event of a DesktopListBox for example pop’s up a Menu on a contextual click. But only in Column 4 (3) and only if it’s a contextual click:
If IsContextualClick Then
Var Column As Integer = Me.ColumnFromXY(x,y)
Var Row As Integer = Me.RowFromXY(x,y)
Me.SelectedRowIndex = Row
If Column = 3 Then
Me.EditCellAt(Row,Column)
Var DMI As New DesktopMenuItem
DMI.AddMenu(New DesktopMenuItem("Import"))
DMI.AddMenu(New DesktopMenuItem("Export"))
DMI.AddMenu(New DesktopMenuItem(DesktopMenuItem.TextSeparator))
DMI.AddMenu(New DesktopMenuItem("Cut"))
DMI.AddMenu(New DesktopMenuItem("Copy"))
DMI.AddMenu(New DesktopMenuItem("Paste"))
Var selectedItem As DesktopMenuItem
selectedItem = DMI.PopUp
End If
End If
And here’s an example with a default Mousebutton click that writes the selected MenuItems Text into the clicked Cell.
Var Column As Integer = Me.ColumnFromXY(x,y)
Var Row As Integer = Me.RowFromXY(x,y)
Me.SelectedRowIndex = Row
If Column = 3 Then
Var DMI As New DesktopMenuItem
DMI.AddMenu(New DesktopMenuItem("Import"))
DMI.AddMenu(New DesktopMenuItem("Export"))
DMI.AddMenu(New DesktopMenuItem(DesktopMenuItem.TextSeparator))
DMI.AddMenu(New DesktopMenuItem("Cut"))
DMI.AddMenu(New DesktopMenuItem("Copy"))
DMI.AddMenu(New DesktopMenuItem("Paste"))
Var selectedItem As DesktopMenuItem
selectedItem = DMI.PopUp
Me.CellTextAt(Row,Column) = selectedItem.Text
End If
If the x and y Values wont work, follow the Docs:
Var xValue As Integer
xValue = System.MouseX - Me.Left - Self.Left ' Calculate current mouse position relative to top left of ListBox
Var yValue As Integer
yValue = System.MouseY - Me.Top - Self.Top ' Calculate current mouse position relative to top of ListBox.
Use piDog Software’s DataView. It is essentially a drop-in equivalent for the Xojo listbox and has a whole bunch of additional features, including popup menus in cells as a standard feature.