How to detect when an icon is dragging over a window

This forum is for general developer support questions.
zzd10h
Posts: 546
Joined: Sun Sep 16, 2012 5:40 am
Location: France

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

Post 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.
http://apps.amistore.net/zTools
X1000 - AmigaOS 4.1.6 / 4.1 FE
User avatar
tonyw
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 1479
Joined: Wed Mar 09, 2011 1:36 pm
Location: Sydney, Australia

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

Post 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.
cheers
tony
zzd10h
Posts: 546
Joined: Sun Sep 16, 2012 5:40 am
Location: France

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

Post 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
http://apps.amistore.net/zTools
X1000 - AmigaOS 4.1.6 / 4.1 FE
User avatar
broadblues
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 600
Joined: Sat Jun 18, 2011 2:40 am
Location: Portsmouth, UK
Contact:

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

Post 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.
zzd10h
Posts: 546
Joined: Sun Sep 16, 2012 5:40 am
Location: France

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

Post by zzd10h »

OK, thank you
http://apps.amistore.net/zTools
X1000 - AmigaOS 4.1.6 / 4.1 FE
chris
Posts: 562
Joined: Sat Jun 18, 2011 11:05 am
Contact:

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

Post 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.
zzd10h
Posts: 546
Joined: Sun Sep 16, 2012 5:40 am
Location: France

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

Post by zzd10h »

Thomas kindly provided a sample on OS4Coding

http://www.os4coding.net/forum/how-dete ... ver-window
http://apps.amistore.net/zTools
X1000 - AmigaOS 4.1.6 / 4.1 FE
User avatar
jaokim
Beta Tester
Beta Tester
Posts: 90
Joined: Sat Jun 18, 2011 12:41 am

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

Post 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
Post Reply