10.24 Lazarus Pascal - macOS - How to show "System Preferences" - "Security & Privacy" programmatically? by Hans.ItemUnderMouse := ListBox1.ItemAtPos(Point(X,Y), true) Īccept:=(ItemUnderMouse>-1) and (ItemUnderMouse-1) and (DraggingItemNumber-1) and (ItemUnderMouse-1) then procedure TForm1.ListBox1MouseDown(Sender: TObject Button: TMouseButton Shift: TShiftState X, Y: Integer) ÄraggingItemNumber := ListBox1.ItemAtPos(Point(X,Y), true) The onDragDrop even is used to "receive" the dropped item and, if everything is legit, move the dragged item to the new location. If that's the case we gladly accept a potential drop (mouse cursor changes). The OnDragOver event is used to make sure the item has a place to drop, on it's own control. We use OnMouseDown to identify that the user clicked a mouse button (this can be left or right mouse button), where we determine if a proper item has been selected and store that item number in the global variable. Next we define 3 procedures for the ListBox events "OnMouseDown", "OnDragDrop", "OnDragOver". This is just an example how you can use Drag and Drop to change the order of items is a TListBox or a TCheckListBox.įirst we define a global variable, this can be a property of TForm1 for example DraggingItemNumber : integer
0 Comments
Leave a Reply. |