473,385 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Mouse won't change (onmousedown="this.style.cursor='different'")

I have set onmousedown to change the cursor, but this setting is ignored
(IE 5.5; NN 6.1 on Win 2K Pro) until the mouse is either moved or the
mouse button is released. On Opera 7.01, the setting seems to be ignored
completely, even when I try with window.setTimeout.

So my two questions are: (1) Most important: Is there anything I can do
so that I don't have to wait for the next mouse event before the cursor
gets repainted. (2) Why is this not working for Opera at all?

The page below can also be found at http://csaba.org/demos/revert.htm

Things I have tried include window.setTimeout for the cursor change,
putting in a <STYLE> section and trying to change the cursor by means
of changing the class, faking a mouse event by putting in a fireEvent to
simulate a mouseMove. Same behaviour as above for all attempts.

This problem also happens on the other side. That is, in a situation
where I have changed the mouse cursor on the down click (subsequently
to moving the mouse) and then I want to revert it on a onmouseup, I
should move the mouse before the cursor changes. That's not nice.

Thanks for any tips,
Csaba Gabor from New York
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<META http-equiv="content-type" content="text/html;charset=iso-8859-1">
<TITLE>Cursor changing demo</TITLE>
</HEAD>
<BODY bgcolor=gold style="margin-left:5%;margin-top:10%">
<DIV style="border:blue 1px solid"
onmouseout="this.style.cursor='auto'"
onmouseover="this.style.cursor='se-resize'"
onmousedown="this.style.cursor='move'">Click and drag</DIV>
<BR><BR><BR>
If you move the mouse over the DIV then its type should change to 'se-resize'.
<BR><BR>
If you now click (and hold) without moving the mouse,
the cursor should change to a 'move' type.
In Opera 7.01 the cursor type does not change at all.

In both IE 5.5 and Netscape 6.1 I either have to release
the mouse button, or move it (with the button still
clicked) in order to get the cursor to change. This does
not seem reasonable.
</BODY>
</HTML>

Jul 20 '05 #1
3 17278
Ahem,

I have figured outsomething for IE and Netscape.
It's not a particularly nice solution (because it represents a large
computational overhead for the browser), but so far on my
smaller test cases it seems to be working on still mouse down
events (without mouse movement).

Replace the onmousedown line as follows:
onmousedown="this.style.cursor='move';window.resiz eBy(1,0);window.resizeBy(-1,0)"

Sadly, it has not made a difference for Opera.
In Netscape 6+, the overhead of the two window.resizeBy calls may be bypassed
by using, instead, window.setCursor('move')

Csaba

"Csaba2000" <ne**@CsabaGabor.com> wrote in message news:bj********@dispatch.concentric.net...
I have set onmousedown to change the cursor, but this setting is ignored
(IE 5.5; NN 6.1 on Win 2K Pro) until the mouse is either moved or the
mouse button is released. On Opera 7.01, the setting seems to be ignored
completely, even when I try with window.setTimeout.

So my two questions are: (1) Most important: Is there anything I can do
so that I don't have to wait for the next mouse event before the cursor
gets repainted. (2) Why is this not working for Opera at all?

The page below can also be found at http://csaba.org/demos/revert.htm

Things I have tried include window.setTimeout for the cursor change,
putting in a <STYLE> section and trying to change the cursor by means
of changing the class, faking a mouse event by putting in a fireEvent to
simulate a mouseMove. Same behaviour as above for all attempts.

This problem also happens on the other side. That is, in a situation
where I have changed the mouse cursor on the down click (subsequently
to moving the mouse) and then I want to revert it on a onmouseup, I
should move the mouse before the cursor changes. That's not nice.

Thanks for any tips,
Csaba Gabor from New York
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<META http-equiv="content-type" content="text/html;charset=iso-8859-1">
<TITLE>Cursor changing demo</TITLE>
</HEAD>
<BODY bgcolor=gold style="margin-left:5%;margin-top:10%">
<DIV style="border:blue 1px solid"
onmouseout="this.style.cursor='auto'"
onmouseover="this.style.cursor='se-resize'"
onmousedown="this.style.cursor='move'">Click and drag</DIV>
<BR><BR><BR>
If you move the mouse over the DIV then its type should change to 'se-resize'.
<BR><BR>
If you now click (and hold) without moving the mouse,
the cursor should change to a 'move' type.
In Opera 7.01 the cursor type does not change at all.

In both IE 5.5 and Netscape 6.1 I either have to release
the mouse button, or move it (with the button still
clicked) in order to get the cursor to change. This does
not seem reasonable.
</BODY>
</HTML>

Jul 20 '05 #2
"Csaba2000" <ne**@CsabaGabor.com> wrote in message
news:bj********@dispatch.concentric.net...
I have figured outsomething for IE and Netscape.
It's not a particularly nice solution (because it represents a large
computational overhead for the browser), but so far on my
smaller test cases it seems to be working on still mouse down
events (without mouse movement).

Replace the onmousedown line as follows:
onmousedown="this.style.cursor='move';
window.resizeBy(1,0);window.resizeBy(-1,0)"
Yuk! I haven't tried it but if the problem is getting IE to redraw the
cursor you might find that toggling the visibility property of the
element that the mouse is over is sufficient. Better than re-sizing the
entire window anyway (would that even work if the user has set F11
(fullscreen)?), as none of the rest of the page would need to be touched
but it should catch the cursor (It might take a timeout on the
re-showing to actually get the re-draw). But there has got to be a
better way, unfortunately I don't have time to look (and won't for at
least another couple of days).
Sadly, it has not made a difference for Opera.
In Netscape 6+, the overhead of the two window.resizeBy
calls may be bypassed by using, instead,
window.setCursor('move')


So:-

if(window.setCursor){
window.setCursor('move');
}else{
. . . //horrible IE hack
}

Richard.
Jul 20 '05 #3
Hurrah Richard!

Good to hear from you.

"Richard Cornford" <ri*****@litotes.demon.co.uk> wrote in message news:bj**********@hercules.btinternet.com...
"Csaba2000" <ne**@CsabaGabor.com> wrote in message
news:bj********@dispatch.concentric.net...
I have figured outsomething for IE and Netscape.
It's not a particularly nice solution (because it represents a large
computational overhead for the browser), but so far on my
smaller test cases it seems to be working on still mouse down
events (without mouse movement).

Replace the onmousedown line as follows:
onmousedown="this.style.cursor='move';
window.resizeBy(1,0);window.resizeBy(-1,0)"
Yuk! I haven't tried it but if the problem is getting IE to redraw the


I agree with both your sentiment and logic. But, after some
investigation, I was not able to get the .style.visibility to work
(which, on reflection, makes sense, since only a local portion of
the page should be redrawn. Though it would also make
sense for this problem not to exist in the first place). In particular,
if I put in a one second delay for making the (target) object visible
again and jiggle the mouse while the target object is hidden, the
mouse reverts to a pointer (which, I'm presuming, is the cursor
type of the underlying element (the body)) from whatever I had
assigned in the onmouseover, and stays that way till I either move
the mouse or release the button.

I didn't try it with .style.display since I figured that was tantamount
to recomputing the entire page, like with resizing.

Interestingly, I also tried making both Netscape and IE full screen,
and the double .resizeBy worked even better since there wasn't
any flicker this time, but the cursor did refresh. Go figure.

If you wind up finding an improvement, and by all rights there
should be one, I would love to hear about it.

Regards from New York,
Csaba
cursor you might find that toggling the visibility property of the
element that the mouse is over is sufficient. Better than re-sizing the
entire window anyway (would that even work if the user has set F11
(fullscreen)?), as none of the rest of the page would need to be touched
but it should catch the cursor (It might take a timeout on the
re-showing to actually get the re-draw). But there has got to be a
better way, unfortunately I don't have time to look (and won't for at
least another couple of days).
Sadly, it has not made a difference for Opera.
In Netscape 6+, the overhead of the two window.resizeBy
calls may be bypassed by using, instead,
window.setCursor('move')


So:-

if(window.setCursor){
window.setCursor('move');
}else{
. . . //horrible IE hack
}

Richard.

Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: punkin | last post by:
I am trying to catch mouse position on the entire screen by dynamically generating mouse click event at every 100 ms. My code only works for IEs but not any Netscape or Gecko-based browsers. The...
5
by: chad.a.morris | last post by:
Hi everyone, I didn't know how to sum this up very well for the title, but hopefully the person(s) will come along who can help. I'm trying to use the window.event.clientX value for...
8
by: NeoAsimov | last post by:
Hello, There is what I want to do. I worked on the problem since 6 hours but I had a problem (probably stupid) and I dont know how to resolve it. I need to have an Mouse Event Click when...
6
by: Carlos García-Carazo | last post by:
Hello, I am working on a C# application for an industrial machine, using Windows Forms, where the user could look at the screen from a 90 degree rotated position, like he could turn the monitor...
2
by: Ryan Liu | last post by:
Hi, I need the MouseDown event be trigged everytime when you press mouse in a datagrid (System.Windows.Forms). But seems mouse event will only fire once, and it seems changed to edit mode...
1
by: Ryan Liu | last post by:
Hi, I need the MouseDown event be trigged everytime when you press mouse in a datagrid (System.Windows.Forms). Hi, I need the MouseDown event be trigged everytime when press mouse in a...
2
by: Rudiga | last post by:
Hi, Is there any kind of mouse over type method in C#, that will change the mouse to a different pointer when the mouse is over a picture box. The reason i as is that i am intending to use a...
6
by: marss | last post by:
Hi, How can I define in Firefox whether the left mouse button is pressed when I move mouse over a html element? The documentation says that "e.button == 0 for standard 'click', usually left...
2
by: wpollans | last post by:
Hello, I need to able to write JS that will click on a link with the middle mouse button - so that the link target will open in a new window or tab - using firefox. Or is there a better (more...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.