TListBox is designed to display 3-10 pictures on the form. You click on the Add button, a TListBoxItem is created with a TImageViewer. The TImageViewer HitTest is disabled. TPopupMenu is tied to both TListBoxItem and TListBox. By long tap should pop up. The Long tap event is triggered, but the menu is not displayed.
I create ListBoxItem
procedure TfmEditObject.AddPhoto(Image: TBitmap); Var item: TListBoxItem; imageV: TImageViewer; begin item := TListBoxItem.Create(lbPhotos); item.parent := lbPhotos; item.text := ''; item.Width := lbPhotos.Width; item.PopupMenu := PopupMenu1; imageV := TImageViewer.Create(lbPhotos); imageV.HitTest := False; imageV.Parent := item; imageV.Align := TAlignLayout.Client; imageV.Bitmap.Assign(image); item.SetFocus; end; The OnGesture event on the ListBox is triggered and reaches the line with the menu display, but the menu does not pop up
procedure TfmEditObject.lbPhotosGesture(Sender: TObject; const EventInfo: TGestureEventInfo; var Handled: Boolean); var c: IControl; ListBox: TListBox; lbxPoint: TPointF; ListBoxItem: TListBoxItem; begin if EventInfo.GestureID = igiLongTap then if (sender is TListBox) and assigned(TListBox(sender).Selected) then begin c := ObjectAtPoint(EventInfo.Location); if Assigned(c) then if Assigned(c.GetObject) then if c.GetObject is TListBox then begin ListBox := TListBox(c.GetObject); lbxPoint := ListBox.AbsoluteToLocal(EventInfo.Location); ListBoxItem := ListBox.ItemByPoint(lbxPoint.X, lbxPoint.Y); if Assigned(ListBoxItem) then begin PopupMenu1.Popup(lbxPoint.X, lbxPoint.Y); ShowMessage(FloatToStr(lbxPoint.X) + ':' + FloatToStr(lbxPoint.Y)); end; Handled := True; end; end; end; A ShowMessage with coordinates pops up. What's wrong? How to show the context menu correctly? Delphi 10.1 Upd 2