Mouse.DragThreshold don't work in ATTabs lazarus / 31-LCL ---------------------------------------------------------------------- AlexTP · 2018-12-24 09:54 Maybe Mouse.DragThreshold is broken? before it worked for me. Now in ATTabs I see that simple pressing on X close-tab-icon starts dragging (so ATTabs shows red vertical line for dragging a tab). I tried Threshold=10, don't help. ---------------------------------------------------------------------- jamie · 2018-12-24 19:46 Did you try ThenControl.Mouse.dragImmediate := False; ---------------------------------------------------------------------- AlexTP · 2018-12-24 20:16 Mouse.DragImmediate:= false is already in ATTabs demo + in CudaText, it helped before (now not). ---------------------------------------------------------------------- jamie · 2018-12-24 20:37 What revision of Lazarus are you using? ---------------------------------------------------------------------- AlexTP · 2018-12-24 20:45 r59906 (trunk). ---------------------------------------------------------------------- jamie · 2018-12-24 21:00 You need to provide a minimum example of failure, possible using a form and couple of objects to drag. --Strange;  I just experimented a little by putting a Tbutton.dragMode := dmManual, and in the MouseDown event I do this  Button1.BeginDrag(false, 20);  This works after I move the mouse 20 pixels, it then goes into drag mode, however, There is no OnClick event!   So if I release the mouse and don't move the cursor, the OnClick never gets called.  Normally the OnClick gets called when the mouse is released which is good and it does that if we don't use dragmode.  Starting drag Mode within the MouseDown and not moving the mouse and then release it, while drag mode is not immediate, does not fire the OnClick event like it should, hmm...  In my old Delphi it does work as stated however, when I enter drag mode using the OnMouseDown event it calles the OnClick immediately instead of calling it on mouseup, but it does call it on OnMouseUp if I don't enter drag Mode manually.  I am not really sure if that is correct but at least it does call the OnClick if you don't hit the threshold on the mouse movement. P.S.  I guess that is not a show stopper, I can still call the event if I wish doing the Assigned Test and then call it. from the Mousedown event. ---------------------------------------------------------------------- AlexTP · 2018-12-25 10:28 I attach demo with simple empty component.  (see Mouse.DragThreshold:= 20; Mouse.DragImmediate:= false) expected: component paints red square only after you drag 20pixels. reality: component paints red square immediately after mouse down+drag. (it shows that Mouse.IsDragging=true) ---------------------------------------------------------------------- jamie · 2018-12-25 20:57 I would bet that you were using a release of Lazarus before mine? I tested that code on 1.8.4 release and it does fail as you say, however, the OnDragOver does not get called until the threshold is met which also changes the cursor at that point.  I tested the "DragDetect" which is only in the Windows unit, inside the OnMouseMove and that does work but you can't tailor the threshold, its set to what ever the user settings are in the system. If you use the Tcontrol.Dragging it seems to work with the first movement but does not seem to adhere to the threshold.  I can work around all of this if I had to but maybe at least the control.dragging flag should work using the threshold settings.  Looks like a bug report to me. ---------------------------------------------------------------------- Josh · 2018-12-26 14:44 Hi I done a test prgram a while ago, when i was having thoughts about the order of things being fired. I have resurected it and used a tbutton a the triggering control ( also added a button to turn Mode on off from automatoc tp manual setting the threshold). on my 1.8.5 I get odd result. You are welcome to disect it, it is not the most elegent written piece of code, but it done the task that I put it. ---------------------------------------------------------------------- zeljko · 2018-12-26 17:17 dmAutomatic really weird effect - imediatelly starts dnd after mouse down , so no waiting for mouse threshold. Manually works ok, but that's not the point. ---------------------------------------------------------------------- jamie · 2018-12-26 20:34 the DragOver event gets called only after the threshold is met.. This is what I found however, in my old Delphi if you have a OnClick event assigned and the control is set for automatic drag, the OnClick event gets called with the Mouse down, otherwise the OnClick event gets called with MouseUp..  With Lazarus, the OnClick event never gets called if a drag operation starts?  Like I said before, I can work around that, it isn't a big deal. ---------------------------------------------------------------------- AlexTP · 2018-12-26 20:45 jamie, issue with OnClick is another one, I need fixing the threshold only. ---------------------------------------------------------------------- jamie · 2018-12-26 21:52 If you read what I said you have your answer. I can not tell you what happen between what versions etc.. Mouse.DragImmediate := false; after this the OnDragOver event starts when the drag has completed the threshold! So place a variable in your control that reports dragging.. Fdragging :Boolean; in mousedownEvent;      fDragging := false; In DragOverEvent;      fDragging := True; from there you can do as you were before with a added check. if (Mouse.Dragging) and (fDragging) Then Writeln(' we are now officially dragging!'; Does that help you? ---------------------------------------------------------------------- AlexTP · 2018-12-26 22:53 It helps, yes. But better to fix LCL code IMHO. ---------------------------------------------------------------------- jamie · 2018-12-26 23:12 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TDragManagerDefault.DragMove(APosition: TPoint);//The captured input device has movedbegin  if FPerformer <> nil then  begin    //delay until the input device has moved at least x pixels    if FWaitForTreshold then      // This needs a Property in the TDragManger Class to detect official movement.    begin      if Abs(FStartPosition.X - APosition.X) >= FThresholdValue then        FWaitForTreshold := false      else      if Abs(FStartPosition.Y - APosition.Y) >= FThresholdValue then        FWaitForTreshold := false      else        exit;      FPerformer.DragStarted(APosition); //     end;    if FPerformer<>nil then      FPerformer.DragMove(APosition);  end;end;                                 There's the code for it in the DragManager.Inc file Good luck. ---------------------------------------------------------------------- jamie · 2018-12-27 01:15 After reviewing this between Delphi and Lazarus behaviors I would say that if you depended on the IsDragging in the past, you could have been doing it incorrectly?  With Delphi if I use the "BeginDrag(False)" and then test for the button.Dragging it returns true while in the MouseDownEvent. The Same happens in the LCL.  In Delphi the MouseMove is skipped while dragging but in Lazarus it is called, so there is a benefit there.  In Delphi when the DragOver is called, it is called at any time the control is Control.dragging is true, before or after the threshold is reached. Here you can test the Control.Dragging and it does report if you are officially dragging.  In Lazarus the DragOver event isn't called until the control enters the threshold. In which case the Control.Dragging will always be true.  I do remember the code was reworked to match Delphi for dragging operations, I think you should adopt your code to use the DrapOver event to make decisions instead of the MouseMove, since MouseMove does not even fire in Delphi during in this operation.  I am using an older version of Delphi but it should still be the same in that respect. ---------------------------------------------------------------------- AlexTP · 2018-12-31 22:39 Thanks for hint with Delphi+MouseOver. I found it by miself too. So fixed Delphi dragging in ATTabs under Delphi.