Listbox Multiselect on touchscreen

https://forum.xojo.com/55073-strange-behavior-when-selecting-multiple-rows-from-a-listbox/0

[quote=469201:@Jeff Tullin]The absence of right-click is the root of most of my gripes about touchscreen/ ipad use.
Its such a useful thing to be able to get options.[/quote]

Actually, there is a convention for the equivalent of right click: long press/Longtap/Long click.

Whatever you call it, when the user maintains his finger on the control for a second, the contextual menu shows up.

Problem is, neither Xojo Desktop nor Web have long click built in. So you need to brew your own. Reset/Start a timer in MouseDown and If MouseUp does not happen before 1000 milliseconds, trigger Action.

Here is code I created precisely for that. Here is the code in the control event handlers:

[code]Function MouseDown(X As Integer, Y As Integer) Handles MouseDown as Boolean
TimerLongPress.Mode = Timer.ModeOff
TimerLongPress.Mode = Timer.ModeSingle

End Function
[/code]

[code]Function MouseUp(X As Integer, Y As Integer) Handles MouseUp as Boolean
TimerLongPress.Mode = Timer.ModeOff

End Function[/code]

Here is the code in the Action event of TimerLongPress which displays the contextualmenu:

[code]Sub Action() Handles Action
dim base as new menuitem

base.append(New MenuItem(“Import”))
base.append(New MenuItem(“Export”))
base.append(New MenuItem(MenuItem.TextSeparator))

base.append(New MenuItem(“Cut”))
base.append(New MenuItem(“Copy”))
base.append(New MenuItem(“Paste”))

Dim selectedMenu As MenuItem
selectedMenu = base.PopUp()

Msgbox("You selected " + selectedMenu.Text)

End Sub
[/code]