Connecting Tech Pros Worldwide Help | Site Map

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

Eric Layman
Guest
 
Posts: n/a
#1: Feb 3 '07
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
Randy Webb
Guest
 
Posts: n/a
#2: Feb 3 '07

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


Eric Layman said the following on 2/4/2007 1:10 AM:
Quote:
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/
Eric Layman
Guest
 
Posts: n/a
#3: Feb 3 '07

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


Thanks.

How does onmousedown and up helps?

Don't they cancel out each other?

"Randy Webb" <HikksNotAtHome@aol.comwrote in message
news:q6SdnX-CquMjOlnY4p2dnA@telcove.net...
Quote:
Eric Layman said the following on 2/4/2007 1:10 AM:
Quote:
>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
kday33@gmail.com
Guest
 
Posts: n/a
#4: Feb 3 '07

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


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.

Randy Webb
Guest
 
Posts: n/a
#5: Feb 3 '07

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


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?
Quote:
Thanks.
>
How does onmousedown and up helps?
It tells you when they hold the mouse down.
Quote:
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/
Eric Layman
Guest
 
Posts: n/a
#6: Feb 3 '07

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



"Randy Webb" <HikksNotAtHome@aol.comwrote in message
news:etydnUGLFJy_QFnY4p2dnA@telcove.net...
Quote:
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?
>
Quote:
>Thanks.
>>
>How does onmousedown and up helps?
>
It tells you when they hold the mouse down.
>
Quote:
>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
Eric Layman
Guest
 
Posts: n/a
#7: Feb 3 '07

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



"Eric Layman" <erricson@layswrote in message
news:1170534204_23209@sp6iad.superfeed.net...
Quote:
>
"Randy Webb" <HikksNotAtHome@aol.comwrote in message
news:etydnUGLFJy_QFnY4p2dnA@telcove.net...
Quote:
>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?
>>
Quote:
>>Thanks.
>>>
>>How does onmousedown and up helps?
>>
>It tells you when they hold the mouse down.
>>
Quote:
>>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
Closed Thread