Page 2 of 2

Re: How to detect when an icon is dragging over a window

Posted: Fri Dec 04, 2015 9:35 pm
by zzd10h
Thank you, Chris, for you reply

"You can read the mouse position from your window structure, and work it out."

I still do that but it returns me the position only when icon is dropped (or mouse is released).

Code: Select all

LONG appDropZone_hook(struct Hook *hook, APTR reserved, struct AppWindowDropZoneMsg *adzm)
{
    kprintf("windows->MouseX (%d) windows->MouseY (%d) \n",windows->MouseX,windows->MouseY) ;
    return 0 ;
}   
"the correct method is to create a DropZone for each one"
Yes, it seems to be complex.

Re: How to detect when an icon is dragging over a window

Posted: Fri Dec 04, 2015 10:51 pm
by tonyw
Another thing you could do is to implement an IntuiTick function that is called every 100 ms, then, within that function, read the mouse co-ordinates and store them globally. That way you will always (well, within 100 ms) know where the mouse is.

That's how the console works when highlighting text.

Re: How to detect when an icon is dragging over a window

Posted: Fri Dec 04, 2015 11:02 pm
by zzd10h
Thank you TonyW for your help.

If you mean a "WA_IDCMP, IDCMP_INTUITICKS" with a

Code: Select all

case WMHI_INTUITICK:
{
    kprintf("INTUITICKS windows->MouseX (%d) windows->MouseY (%d) \n",windows->MouseX,windows->MouseY) ;
}
break ;
I tried it but the problem is that it's called only when the window is active, therefore it's not called when a icon is dragging on the window but only when it's dropped.

I will try with a timer...

edit : same problem with a timer, as soon as I click LMB to drag an icon, my program is in "paused" state.
Even my WB clock is stopped as soon as I drag a workbench file/drawer, is it normal ?

Thx

Re: How to detect when an icon is dragging over a window

Posted: Sat Dec 05, 2015 12:45 am
by broadblues
Even my WB clock is stopped as soon as I drag a workbench file/drawer, is it normal ?
Yes.

You have to bite the bullet and do it properly, all "hacky" shortcuts will get you in trouble eventually.

Create a drop zone for each area of interest and handle it accordingly.

Re: How to detect when an icon is dragging over a window

Posted: Sat Dec 05, 2015 7:48 pm
by zzd10h
OK, thank you

Re: How to detect when an icon is dragging over a window

Posted: Sun Dec 06, 2015 12:13 am
by chris
zzd10h wrote:Thank you, Chris, for you reply

"You can read the mouse position from your window structure, and work it out."

I still do that but it returns me the position only when icon is dropped (or mouse is released).

Code: Select all

LONG appDropZone_hook(struct Hook *hook, APTR reserved, struct AppWindowDropZoneMsg *adzm)
{
    kprintf("windows->MouseX (%d) windows->MouseY (%d) \n",windows->MouseX,windows->MouseY) ;
    return 0 ;
}   
Sorry, I meant check the mouse position during IDCMP_MOUSEMOVE events.

That might require the window to be active though.

Re: How to detect when an icon is dragging over a window

Posted: Sun Dec 06, 2015 8:10 pm
by zzd10h
Thomas kindly provided a sample on OS4Coding

http://www.os4coding.net/forum/how-dete ... ver-window

Re: How to detect when an icon is dragging over a window

Posted: Tue Jan 05, 2016 12:51 pm
by jaokim
zzd10h wrote:Thomas kindly provided a sample on OS4Coding

http://www.os4coding.net/forum/how-dete ... ver-window
The topic was renamed: http://www.os4coding.net/forum/solved-h ... ver-window