470,612 Members | 2,437 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,612 developers. It's quick & easy.

Is there a way to detect a held-down button while the mouse is moving?

Is there a way to detect a held-down button while
the mouse is moving?

Thanks.

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Feb 3 '07 #1
6 3371
Eric Layman said the following on 2/4/2007 1:10 AM:
Is there a way to detect a held-down button while
the mouse is moving?
onmousedown and onmouseup

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Feb 3 '07 #2
Thanks.

How does onmousedown and up helps?

Don't they cancel out each other?

"Randy Webb" <Hi************@aol.comwrote in message
news:q6********************@telcove.net...
Eric Layman said the following on 2/4/2007 1:10 AM:
>Is there a way to detect a held-down button while
the mouse is moving?

onmousedown and onmouseup

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices -
http://www.JavascriptToolbox.com/bestpractices/


Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Feb 3 '07 #3
onmousedown tells you when they started holding the mouse button down.

The time between onmousedown and onmouseup is the time that the user
is holding the mouse down.

When onmouseup is called, it means the user has let go of the mouse.

Feb 3 '07 #4
Eric Layman said the following on 2/4/2007 2:58 AM:

Answer:It destroys the order of the conversation
Question: Why?
Answer: Top-Posting.
Question: Whats the most annoying thing on Usenet?
Thanks.

How does onmousedown and up helps?
It tells you when they hold the mouse down.
Don't they cancel out each other?
No. The onmousedown gets triggered, they drag the mouse, the mouse is
released and the onmouseup gets triggered.

onmousedown="var mouseIsDown=true"
onmousedown="var mouseIsDown=false"

And then when the mouse is being dragged/moved, you check the state of
mouseIsDown.

Your posting agent is severely broken.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Feb 3 '07 #5

"Randy Webb" <Hi************@aol.comwrote in message
news:et********************@telcove.net...
Eric Layman said the following on 2/4/2007 2:58 AM:

Answer:It destroys the order of the conversation
Question: Why?
Answer: Top-Posting.
Question: Whats the most annoying thing on Usenet?
>Thanks.

How does onmousedown and up helps?

It tells you when they hold the mouse down.
>Don't they cancel out each other?

No. The onmousedown gets triggered, they drag the mouse, the mouse is
released and the onmouseup gets triggered.

onmousedown="var mouseIsDown=true"
onmousedown="var mouseIsDown=false"

And then when the mouse is being dragged/moved, you check the state of
mouseIsDown.

Your posting agent is severely broken.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices -
http://www.JavascriptToolbox.com/bestpractices/
Thanks for the advice!

Here's the script I've conjured based on your tips!

My idea is to have multiple selection of table cells if user holds the mouse
down and "drags" the mouse over other cells.

But now I have problem with "deselecting" the selected cells. My logic seems
flawed here. (yes i know the html is malformed. i just wanna test out the
idea =) )

Any comments?

<script language="javascript">
var mouseIsDown = false;

function md()
{
mouseIsDown = true;
}

function mu()
{
mouseIsDown = false;
}

function check(cid)
{
var obj;
obj = document.getElementById(cid);
if(mouseIsDown)
{
if(obj.getAttribute('bgColor')=="blue")
{
obj.getAttributesetAttribute('bgColor','white');
}
else(obj.getAttribute('bgColor')=="white")
{
obj.setAttribute('bgColor','blue');
}
}
}
</script>
<body id="b1" >
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td id="d1" onMouseDown="md();" onMouseUp="mu();"
onMouseOver="check('d1');">&nbsp;</td>
<td id="d2" onMouseDown="md();" onMouseUp="mu();"
onMouseOver="check('d2');">&nbsp;</td>
</tr>
<tr>
<td id="d3" onMouseDown="md();" onMouseUp="mu();"
onMouseOver="check('d3');">&nbsp;</td>
<td id="d4" onMouseDown="md();" onMouseUp="mu();"
onMouseOver="check('d4');">&nbsp;</td>
</tr>
<tr>
<td id="d5" onMouseDown="md();" onMouseUp="mu();"
onMouseOver="check('d5');">&nbsp;</td>
<td id="d6" onMouseDown="md();" onMouseUp="mu();"
onMouseOver="check('d6');">&nbsp;</td>
</tr>
<tr>
<td id="d7" onMouseDown="md();" onMouseUp="mu();"
onMouseOver="check('d7');">&nbsp;</td>
<td id="d8" onMouseDown="md();" onMouseUp="mu();"
onMouseOver="check('d8');">&nbsp;</td>
</tr>
<tr>
<td id="d9" onMouseDown="md();" onMouseUp="mu();"
onMouseOver="check('d9');">&nbsp;</td>
<td id="d10" onMouseDown="md();" onMouseUp="mu();"
onMouseOver="check('d10');">&nbsp;</td>
</tr>
<tr>
<td id="d11" onMouseDown="md();" onMouseUp="mu();"
onMouseOver="check('d11');">&nbsp;</td>
<td id="d12" onMouseDown="md();" onMouseUp="mu();"
onMouseOver="check('d12');">&nbsp;</td>
</tr>
<tr>
<td id="d13" onMouseDown="md();" onMouseUp="mu();"
onMouseOver="check('d13');">&nbsp;</td>
<td id="d14" onMouseDown="md();" onMouseUp="mu();"
onMouseOver="check('d14');">&nbsp;</td>
</tr>
<tr>
<td id="d15" onMouseDown="md();" onMouseUp="mu();"
onMouseOver="check('d15');">&nbsp;</td>
<td id="d16" onMouseDown="md();" onMouseUp="mu();"
onMouseOver="check('d16');">&nbsp;</td>
</tr>
<tr>
<td id="d17" onMouseDown="md();" onMouseUp="mu();"
onMouseOver="check('d17');">&nbsp;</td>
<td id="d18" onMouseDown="md();" onMouseUp="mu();"
onMouseOver="check('d18');">&nbsp;</td>
</tr>
</table>
</body>

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Feb 3 '07 #6

"Eric Layman" <erricson@layswrote in message
news:11**************@sp6iad.superfeed.net...
>
"Randy Webb" <Hi************@aol.comwrote in message
news:et********************@telcove.net...
>Eric Layman said the following on 2/4/2007 2:58 AM:

Answer:It destroys the order of the conversation
Question: Why?
Answer: Top-Posting.
Question: Whats the most annoying thing on Usenet?
>>Thanks.

How does onmousedown and up helps?

It tells you when they hold the mouse down.
>>Don't they cancel out each other?

No. The onmousedown gets triggered, they drag the mouse, the mouse is
released and the onmouseup gets triggered.

onmousedown="var mouseIsDown=true"
onmousedown="var mouseIsDown=false"

And then when the mouse is being dragged/moved, you check the state of
mouseIsDown.

Your posting agent is severely broken.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices -
http://www.JavascriptToolbox.com/bestpractices/

Thanks for the advice!

Here's the script I've conjured based on your tips!

My idea is to have multiple selection of table cells if user holds the
mouse down and "drags" the mouse over other cells.

But now I have problem with "deselecting" the selected cells. My logic
seems flawed here. (yes i know the html is malformed. i just wanna test
out the idea =) )

Any comments?

<script language="javascript">
var mouseIsDown = false;

function md()
{
mouseIsDown = true;
}

function mu()
{
mouseIsDown = false;
}

function check(cid)
{
var obj;
obj = document.getElementById(cid);
if(mouseIsDown)
{
if(obj.getAttribute('bgColor')=="blue")
{
obj.getAttributesetAttribute('bgColor','white');
}
else(obj.getAttribute('bgColor')=="white")
{
obj.setAttribute('bgColor','blue');
}
}
}
</script>
<body id="b1" >
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td id="d1" onMouseDown="md();" onMouseUp="mu();"
onMouseOver="check('d1');">&nbsp;</td>
<td id="d2" onMouseDown="md();" onMouseUp="mu();"
onMouseOver="check('d2');">&nbsp;</td>
</tr>
<tr>
<td id="d3" onMouseDown="md();" onMouseUp="mu();"
onMouseOver="check('d3');">&nbsp;</td>
<td id="d4" onMouseDown="md();" onMouseUp="mu();"
onMouseOver="check('d4');">&nbsp;</td>
</tr>
<tr>
<td id="d5" onMouseDown="md();" onMouseUp="mu();"
onMouseOver="check('d5');">&nbsp;</td>
<td id="d6" onMouseDown="md();" onMouseUp="mu();"
onMouseOver="check('d6');">&nbsp;</td>
</tr>
<tr>
<td id="d7" onMouseDown="md();" onMouseUp="mu();"
onMouseOver="check('d7');">&nbsp;</td>
<td id="d8" onMouseDown="md();" onMouseUp="mu();"
onMouseOver="check('d8');">&nbsp;</td>
</tr>
<tr>
<td id="d9" onMouseDown="md();" onMouseUp="mu();"
onMouseOver="check('d9');">&nbsp;</td>
<td id="d10" onMouseDown="md();" onMouseUp="mu();"
onMouseOver="check('d10');">&nbsp;</td>
</tr>
<tr>
<td id="d11" onMouseDown="md();" onMouseUp="mu();"
onMouseOver="check('d11');">&nbsp;</td>
<td id="d12" onMouseDown="md();" onMouseUp="mu();"
onMouseOver="check('d12');">&nbsp;</td>
</tr>
<tr>
<td id="d13" onMouseDown="md();" onMouseUp="mu();"
onMouseOver="check('d13');">&nbsp;</td>
<td id="d14" onMouseDown="md();" onMouseUp="mu();"
onMouseOver="check('d14');">&nbsp;</td>
</tr>
<tr>
<td id="d15" onMouseDown="md();" onMouseUp="mu();"
onMouseOver="check('d15');">&nbsp;</td>
<td id="d16" onMouseDown="md();" onMouseUp="mu();"
onMouseOver="check('d16');">&nbsp;</td>
</tr>
<tr>
<td id="d17" onMouseDown="md();" onMouseUp="mu();"
onMouseOver="check('d17');">&nbsp;</td>
<td id="d18" onMouseDown="md();" onMouseUp="mu();"
onMouseOver="check('d18');">&nbsp;</td>
</tr>
</table>
</body>
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
An amended version. finally got de-selection to work:

<script language="javascript">
var mouseIsDown = false;

function md()
{
mouseIsDown = true;
}

function mu()
{
mouseIsDown = false;
}

function check(cid)
{
var obj;
obj = document.getElementById(cid);
var bgc = obj.getAttribute('bgColor');
if(mouseIsDown==true)
{
if(bgc=="")
{
obj.setAttribute('bgColor','blue');
}
else
{
obj.setAttribute('bgColor','white');
}
}
}
</script>
<body id="b1">
<div onMouseUp="mu();">
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td id="d1" onMouseDown="md();" onMouseUp="mu();"
onMouseOver="check('d1');">&nbsp;</td>
<td id="d2" onMouseDown="md();" onMouseUp="mu();"
onMouseOver="check('d2');">&nbsp;</td>
</tr>
<tr>
<td id="d3" onMouseDown="md();" onMouseUp="mu();"
onMouseOver="check('d3');">&nbsp;</td>
<td id="d4" onMouseDown="md();" onMouseUp="mu();"
onMouseOver="check('d4');">&nbsp;</td>
</tr>
<tr>
<td id="d5" onMouseDown="md();" onMouseUp="mu();"
onMouseOver="check('d5');">&nbsp;</td>
<td id="d6" onMouseDown="md();" onMouseUp="mu();"
onMouseOver="check('d6');">&nbsp;</td>
</tr>
<tr>
<td id="d7" onMouseDown="md();" onMouseUp="mu();"
onMouseOver="check('d7');">&nbsp;</td>
<td id="d8" onMouseDown="md();" onMouseUp="mu();"
onMouseOver="check('d8');">&nbsp;</td>
</tr>
<tr>
<td id="d9" onMouseDown="md();" onMouseUp="mu();"
onMouseOver="check('d9');">&nbsp;</td>
<td id="d10" onMouseDown="md();" onMouseUp="mu();"
onMouseOver="check('d10');">&nbsp;</td>
</tr>
<tr>
<td id="d11" onMouseDown="md();" onMouseUp="mu();"
onMouseOver="check('d11');">&nbsp;</td>
<td id="d12" onMouseDown="md();" onMouseUp="mu();"
onMouseOver="check('d12');">&nbsp;</td>
</tr>
<tr>
<td id="d13" onMouseDown="md();" onMouseUp="mu();"
onMouseOver="check('d13');">&nbsp;</td>
<td id="d14" onMouseDown="md();" onMouseUp="mu();"
onMouseOver="check('d14');">&nbsp;</td>
</tr>
<tr>
<td id="d15" onMouseDown="md();" onMouseUp="mu();"
onMouseOver="check('d15');">&nbsp;</td>
<td id="d16" onMouseDown="md();" onMouseUp="mu();"
onMouseOver="check('d16');">&nbsp;</td>
</tr>
<tr>
<td id="d17" onMouseDown="md();" onMouseUp="mu();"
onMouseOver="check('d17');">&nbsp;</td>
<td id="d18" onMouseDown="md();" onMouseUp="mu();"
onMouseOver="check('d18');">&nbsp;</td>
</tr>
</table>
</div>
</body>

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Feb 3 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

39 posts views Thread by David Jubinville | last post: by
1 post views Thread by Claude Vernier | last post: by
4 posts views Thread by sanjana | last post: by
2 posts views Thread by Hank | last post: by
7 posts views Thread by Adam Benson | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.