Closed Thread Icon

Topic awaiting preservation: detecting mouse leaving window area? (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=8369" title="Pages that link to Topic awaiting preservation: detecting mouse leaving window area? (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: detecting mouse leaving window area? <span class="small">(Page 1 of 1)</span>\

 
Dracusis
Maniac (V) Inmate

From: Brisbane, Australia
Insane since: Apr 2001

posted posted 10-29-2002 16:10

Is it possible to detect when the mouse leaves the browser's window boundry?

I thought I could do this using event.screenX and event.screenY while monitoring the window size and position but screenX/Y aren't captured when the mouse moces out of the document.

Can I attatch the mousemove handeler to something that will fire anywhere, even outside of the window, when the current window is in focus?

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 10-29-2002 18:53

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 10-29-2002 21:08

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

Dracusis
Maniac (V) Inmate

From: Brisbane, Australia
Insane since: Apr 2001

posted posted 10-30-2002 03:40

err what?

I have no idea what you just said but I fear you just told me it wasn't possible.

Dang it! Is there any way to tell if the mouse leaves a browser?s view pane? I don't need to track the mouse after that, I just need to know that it's no longer inside the view pane of the browser window. There has to be some way to do it. I don't care how dodgy it is, just as long as it works.

I though about checking to see what the mouse's x and y position and if it gets within 1 to 5 pixels of the doucment's boundries then I'd know but the mouse capturing isn't that accurate. If the mouse exits the document area at a great speed the last value may be up to about 15 pixels inside the document edge it left. Poo!

Any suggestions would be appreciated.

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 10-30-2002 03:43

Hmm. I don't think there's any way to detect that directly. However, there may be a workaround, depending on your goal. What, exactly, are you trying to achieve?

Dracusis
Maniac (V) Inmate

From: Brisbane, Australia
Insane since: Apr 2001

posted posted 10-30-2002 04:58

Ok, it's relating to the scroller i made recently:
http://www.whatever.net.au/~cameron/files/scripts/scroller/scroller.html

If you start draging the tab/slider bit and you drag the mouse out of the window and relase the mouse button, when the mouse comes back into the window again it won't have captured the onMouseUp and won't cancle the draging action. Which is rather annoying.

edit: Oops, that's not the latest version and hence it still a little buggy in IE (espically when you drag the cursor across the text) but the same problem still happens.

[This message has been edited by Dracusis (edited 10-30-2002).]

DocOzone
Maniac (V) Lord Mad Scientist
Sovereign of all the lands Ozone and just beyond that little green line over there...

From: Stockholm, Sweden
Insane since: Mar 1994

posted posted 10-30-2002 13:59

I've done a hack before where I placed a "gutter space", 50px, all the way around the edge of my display window. If you drag into that window area, it fires the same function as when you release the mouse. There are other ways that seem like they *should* work, but I've had no luck.

Your pal, -doc-

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 10-30-2002 14:11

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 10-30-2002 15:32

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 10-30-2002 17:43

it's not a big deal you just need to get the window info and the mouse pos
here's some top of my head code IE only right now

maxX = window.innerWidth - 50;
maxY = window.innerHeight - 50
minX = 50
miny = 50

document.onmousemove = track;

function track() {
mouseX = event.x
mousey = event.y
if ((mouseX > maxX)

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 10-30-2002 17:51

Dracusis' problem is that his scroller is right up against the edge of the browser window, so that solution doesn't work, I'm afraid.

Try onmouseout events on anything you can, dracusis, and see if any of them respond correctly.

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 10-30-2002 18:02

hmm.

Total hack on this one but what about this. take that track function and do something like this.

document.onmousemove = track;
timer = false
function track() {
if(timer) clearTimeout(timer);
timer = setTimeout('killScroll()', 1000);
}

Might be a CPU hog though.




.:[ Never resist a perfect moment ]:.

[This message has been edited by bitdamaged (edited 10-30-2002).]

Dracusis
Maniac (V) Inmate

From: Brisbane, Australia
Insane since: Apr 2001

posted posted 10-31-2002 01:45

Ok, I think I can work out a plausable solution given the suggestions here. Thanks a lot everyone!

I did find a quick'n easy fix IE:

<body onmouseout="window.status='Out!';return true" onmouseover="window.status='Over!';return true">

Works quite well but the event does propagate a little so I'd need to put a small timer on it. Mozilla 1.1 had problems catching the onMouseOut, again it comes back to how fast the cursor exits the document. Opera doesn't seem to notice the onMouseOut at all. Edit: Actually, it works really well in opera 6 if the mouse button is pressed when it leaves the window... how odd. Only one left to fix now is Mozilla.

The 50px gutter idea would would great if the scroller wasn't up against the window edge, so I'll hang on to that idea for when it isn't as that would be a lot simpler.

Bitdamaged:

document.onmousemove = track;
timer = false
function track() {
if(timer) clearTimeout(timer);
timer = setTimeout('killScroll()', 1000);
}

That would kill the scroller if the mouse hasn't moved for one second yah? I thought about doing that too but I quite often won't move my mouse at all for several seconds while still holding the mouse button down over a scrollbar. If it all of a sudden stopped working and I have to reclick it then I'd be a little miffed. Although a combination of that and the gutter idea might will wonders for some of the other versions I have planned. =)

I was also thinking I could make another DIV underneath all of the others that would efectively work as a container for the scroll area, the problem here being that onMouseOut is likely to fire all the time given the ammount of content above it, and I'm hopeless at canceling events. Then I was thinking I could make this DIV above everything else with a transparent GIF in it (which would be perfect), but that would render any hyperlinks in the scrollers content area useless. Darn it!

Slime, the problem I have with attaching onMouseOut to something is that it usually propergates/bubbles when there are other elements above or below it and I have no idea how to deal with that.

Anyone know how to replicate MSIE's onMouseEnter and onMouseLeave events cross-browser? hah....

When I first made the scroller I decided to base all of the mouse events (Including the onMouseOver/Out) on the cursor position. I use this bit of code to do that:

makeLayer.prototype.mouseInside = function(mX,mY,bX,bY) {
if ((mX >= (this.l-bX)) && (mX <= (this.r+bX)) && (mY >= (this.t-bY)) && (mY <= (this.b+bY))) {return true} else {return false}}

mX & mY are the mouse X & Y positions passed to the function. bX & bY are the X/Y buffer distance, "this" in the object in question. bX and bY allow me to detect if the mouse is within x number of pixels of that object. So I was thinking I can use this as a double check for the browsers that don't support <body onmouseout=""> very well. and just extend the distance for the checking to cover the whoe area of the scroller.

... Wow. Long post. Oops. Anyways, thanks a heap for the ideas. I should be able to figure something out.

[This message has been edited by Dracusis (edited 10-31-2002).]

Dracusis
Maniac (V) Inmate

From: Brisbane, Australia
Insane since: Apr 2001

posted posted 11-01-2002 08:31

Ok, now I'm confused. I was flipp'n through slimes old site:

http://www.slimeland.com/cyanslime/

I was playing with his scroller and some how the mouse keeps tracking outside the window! How the hell did you do that?

I tried look at your code but I couldn't see anything special about it. ~scratches head~

[This message has been edited by Dracusis (edited 11-01-2002).]

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 11-01-2002 15:17

You know, it's funny, 'cause I was thinking about that, and I can't remember how I did it. I thought I had just let it go, assuming it'd never be a problem.

Woah, it seems that mine continues to detect mouse move events even when the mouse is out of the window! Weird. Let's see how I detected events...

Looks like I didn't do anything special, just attached them to the document object. Hmm.

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 11-01-2002 16:48

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

Dracusis
Maniac (V) Inmate

From: Brisbane, Australia
Insane since: Apr 2001

posted posted 11-01-2002 17:09

Yeah, doc's works outside the window too. ~stamps feet~ That's Unfair!

Maybe it's something in my code that's stopping it from firing when the mouse is out of the window. I'll have to play around with some test pages to see if I can figure out why, how and when the mousemove event works.

« BackwardsOnwards »

Show Forum Drop Down Menu