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

Discussion in 'Javascript' started by Csaba2000, Sep 11, 2003.

  1. Csaba2000

    Csaba2000 Guest

    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>
    Csaba2000, Sep 11, 2003
    #1
    1. Advertising

  2. Csaba2000

    Csaba2000 Guest

    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.resizeBy(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" <> wrote in message news:bjqii8$...
    > 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>
    >
    >
    >
    Csaba2000, Sep 12, 2003
    #2
    1. Advertising

  3. "Csaba2000" <> wrote in message
    news:bjr5dd$...
    >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.
    Richard Cornford, Sep 12, 2003
    #3
  4. Csaba2000

    Csaba2000 Guest

    Hurrah Richard!

    Good to hear from you.

    "Richard Cornford" <> wrote in message news:bjr84q$mcp$...
    > "Csaba2000" <> wrote in message
    > news:bjr5dd$...
    > >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.
    >
    Csaba2000, Sep 12, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kyzer
    Replies:
    2
    Views:
    756
    Duane Hebert
    May 6, 2005
  2. Jerry O

    OnMouseDown in NN4.7

    Jerry O, Sep 2, 2003, in forum: Javascript
    Replies:
    1
    Views:
    83
    Stuart Palmer
    Sep 3, 2003
  3. Stefan Mueller
    Replies:
    0
    Views:
    354
    Stefan Mueller
    Jan 28, 2006
  4. torbs
    Replies:
    2
    Views:
    95
    torbs
    May 2, 2006
  5. stef
    Replies:
    2
    Views:
    76
Loading...

Share This Page