Recent

Author Topic: Mouse.DragThreshold don't work in ATTabs  (Read 5102 times)

AlexTP

  • Hero Member
  • *****
  • Posts: 2406
    • UVviewsoft
Mouse.DragThreshold don't work in ATTabs
« on: December 24, 2018, 10:54:05 am »
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.
« Last Edit: December 24, 2018, 10:58:15 am by Alextp »

jamie

  • Hero Member
  • *****
  • Posts: 6131
Re: Mouse.DragThreshold don't work in ATTabs
« Reply #1 on: December 24, 2018, 08:46:32 pm »
Did you try
ThenControl.Mouse.dragImmediate := False;


The only true wisdom is knowing you know nothing

AlexTP

  • Hero Member
  • *****
  • Posts: 2406
    • UVviewsoft
Re: Mouse.DragThreshold don't work in ATTabs
« Reply #2 on: December 24, 2018, 09:16:04 pm »
Mouse.DragImmediate:= false
is already in ATTabs demo + in CudaText, it helped before (now not).

jamie

  • Hero Member
  • *****
  • Posts: 6131
Re: Mouse.DragThreshold don't work in ATTabs
« Reply #3 on: December 24, 2018, 09:37:40 pm »
What revision of Lazarus are you using?
The only true wisdom is knowing you know nothing

AlexTP

  • Hero Member
  • *****
  • Posts: 2406
    • UVviewsoft
Re: Mouse.DragThreshold don't work in ATTabs
« Reply #4 on: December 24, 2018, 09:45:00 pm »
r59906 (trunk).

jamie

  • Hero Member
  • *****
  • Posts: 6131
Re: Mouse.DragThreshold don't work in ATTabs
« Reply #5 on: December 24, 2018, 10:00:16 pm »
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.
« Last Edit: December 24, 2018, 11:42:15 pm by jamie »
The only true wisdom is knowing you know nothing

AlexTP

  • Hero Member
  • *****
  • Posts: 2406
    • UVviewsoft
Re: Mouse.DragThreshold don't work in ATTabs
« Reply #6 on: December 25, 2018, 11:28:08 am »
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

  • Hero Member
  • *****
  • Posts: 6131
Re: Mouse.DragThreshold don't work in ATTabs
« Reply #7 on: December 25, 2018, 09:57:51 pm »
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.

The only true wisdom is knowing you know nothing

Josh

  • Hero Member
  • *****
  • Posts: 1274
Re: Mouse.DragThreshold don't work in ATTabs
« Reply #8 on: December 26, 2018, 03:44:49 pm »
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.
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

zeljko

  • Hero Member
  • *****
  • Posts: 1596
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: Mouse.DragThreshold don't work in ATTabs
« Reply #9 on: December 26, 2018, 06:17:31 pm »
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

  • Hero Member
  • *****
  • Posts: 6131
Re: Mouse.DragThreshold don't work in ATTabs
« Reply #10 on: December 26, 2018, 09:34:11 pm »
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.
The only true wisdom is knowing you know nothing

AlexTP

  • Hero Member
  • *****
  • Posts: 2406
    • UVviewsoft
Re: Mouse.DragThreshold don't work in ATTabs
« Reply #11 on: December 26, 2018, 09:45:21 pm »
jamie,
issue with OnClick is another one, I need fixing the threshold only.

jamie

  • Hero Member
  • *****
  • Posts: 6131
Re: Mouse.DragThreshold don't work in ATTabs
« Reply #12 on: December 26, 2018, 10:52:47 pm »
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?

The only true wisdom is knowing you know nothing

AlexTP

  • Hero Member
  • *****
  • Posts: 2406
    • UVviewsoft
Re: Mouse.DragThreshold don't work in ATTabs
« Reply #13 on: December 26, 2018, 11:53:55 pm »
It helps, yes. But better to fix LCL code IMHO.

jamie

  • Hero Member
  • *****
  • Posts: 6131
Re: Mouse.DragThreshold don't work in ATTabs
« Reply #14 on: December 27, 2018, 12:12:44 am »
Code: Pascal  [Select][+][-]
  1. procedure TDragManagerDefault.DragMove(APosition: TPoint);
  2. //The captured input device has moved
  3. begin
  4.   if FPerformer <> nil then
  5.   begin
  6.     //delay until the input device has moved at least x pixels
  7.     if FWaitForTreshold then      // This needs a Property in the TDragManger Class to detect official movement.
  8.     begin
  9.       if Abs(FStartPosition.X - APosition.X) >= FThresholdValue then
  10.         FWaitForTreshold := false
  11.       else
  12.       if Abs(FStartPosition.Y - APosition.Y) >= FThresholdValue then
  13.         FWaitForTreshold := false
  14.       else
  15.         exit;
  16.       FPerformer.DragStarted(APosition); //
  17.     end;
  18.     if FPerformer<>nil then
  19.       FPerformer.DragMove(APosition);
  20.   end;
  21. end;                                
  22.  

There's the code for it in the DragManager.Inc file

Good luck.
The only true wisdom is knowing you know nothing

 

TinyPortal © 2005-2018