<a href="#" onmousedown="ca llMyFunction()" >Press the mouse button</a>
What I expect is when I or an user move mouse pointer over that link,
and press the mouse button. Then will "callMyFunction ()" over and
over again until I release the mouse button (mouseup).
But what I found out the onmousedown is just acts the same as onclick.
It only "callMyFunction " once. If I want to call again, I need to
keep repeat mousedown, mouseup like clicking. That is not cool at all!
So The implementation for onmousedown in JavaScript is different from
mousePressed event in MouseListener interface in Java. 6 4751
RC wrote:
<a href="#" onmousedown="ca llMyFunction()" >Press the mouse button</a>
What I expect is when I or an user move mouse pointer over that link,
and press the mouse button. Then will "callMyFunction ()" over and
over again until I release the mouse button (mouseup).
But what I found out the onmousedown is just acts the same as onclick.
It only "callMyFunction " once. If I want to call again, I need to
keep repeat mousedown, mouseup like clicking. That is not cool at all!
Why not implement it so that once they click, your function will
continuously be called. However, on an onmouseout event, you can make
it so that the "callMyFunction " function stops being called.
So The implementation for onmousedown in JavaScript is different from
mousePressed event in MouseListener interface in Java.
Probably, since Java != JavaScript.
RC said the following on 7/26/2006 4:29 PM:
<a href="#" onmousedown="ca llMyFunction()" >Press the mouse button</a>
What I expect is when I or an user move mouse pointer over that link,
and press the mouse button. Then will "callMyFunction ()" over and
over again until I release the mouse button (mouseup).
But what I found out the onmousedown is just acts the same as onclick.
It only "callMyFunction " once. If I want to call again, I need to
keep repeat mousedown, mouseup like clicking. That is not cool at all!
So The implementation for onmousedown in JavaScript is different from
mousePressed event in MouseListener interface in Java.
onmousedown="ca llMyFunction()"
onmouseup="var keepCallingIt = false"
onclick="return false"
var keepCallingIt = true;
function callMyFunction( ){
//code here for callMyFunction
if(keepCallingI t){
callMyFunction( )
}
}
--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Randy Webb wrote:
RC said the following on 7/26/2006 4:29 PM:
<a href="#" onmousedown="ca llMyFunction()" >Press the mouse button</a>
What I expect is when I or an user move mouse pointer over that link,
and press the mouse button. Then will "callMyFunction ()" over and
over again until I release the mouse button (mouseup).
But what I found out the onmousedown is just acts the same as onclick.
It only "callMyFunction " once. If I want to call again, I need to
keep repeat mousedown, mouseup like clicking. That is not cool at all!
So The implementation for onmousedown in JavaScript is different from
mousePressed event in MouseListener interface in Java.
onmousedown="ca llMyFunction()"
onmouseup="var keepCallingIt = false"
onclick="return false"
var keepCallingIt = true;
function callMyFunction( ){
//code here for callMyFunction
if(keepCallingI t){
callMyFunction( )
}
}
Wont that create a deeply recursive function? If the mouse button is
held down for some time, it will likley cause a problem.
It may be better to use setTimeout onmousedown, then cancel it
onmouseup, e.g.:
<script type="text/javascript">
var pageCounter = (function(){
var isRunning;
return {
start : function(){
var d = document.getEle mentById('xx');
d.innerHTML = +d.innerHTML + 1;
isRunning = setTimeout('pag eCounter.start( );', 100);
},
stop : function (){
if (isRunning) clearTimeout(is Running);
}
}
})();
</script>
<a href="#"
onmousedown="pa geCounter.start ();"
onmouseup="page Counter.stop(); "
>start/stop</a>
<div id="xx">0</div>
--
Rob
RC wrote:
<snip>
So The implementation for onmousedown in JavaScript is
different from mousePressed event in MouseListener interface
in Java.
Richard.
RobG said the following on 7/27/2006 1:42 AM:
Randy Webb wrote:
>RC said the following on 7/26/2006 4:29 PM:
>><a href="#" onmousedown="ca llMyFunction()" >Press the mouse button</a>
What I expect is when I or an user move mouse pointer over that link, and press the mouse button. Then will "callMyFunction ()" over and over again until I release the mouse button (mouseup).
But what I found out the onmousedown is just acts the same as onclick. It only "callMyFunction " once. If I want to call again, I need to keep repeat mousedown, mouseup like clicking. That is not cool at all!
So The implementation for onmousedown in JavaScript is different from mousePresse d event in MouseListener interface in Java.
onmousedown="c allMyFunction() " onmouseup="v ar keepCallingIt = false" onclick="retur n false"
var keepCallingIt = true; function callMyFunction( ){ //code here for callMyFunction if(keepCalling It){ callMyFunction () } }
Wont that create a deeply recursive function?
Absolutely <g>
If the mouse button is held down for some time, it will likley cause a problem.
It's not "likely", rather its pretty dependable.
It may be better to use setTimeout onmousedown, then cancel it
onmouseup, e.g.:
Depending on what you want. At 13ms timeout, you can only execute it
once every 13ms, whereas with the recursion it happens as fast as the
processor can process the script.
--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Randy Webb wrote:
RobG said the following on 7/27/2006 1:42 AM:
[...]
Wont that create a deeply recursive function?
Absolutely <g>
Firefox seems to allow 1,000 recursions before a 'too much recursion'
error occurs. Maybe there's a setting somewhere to change that... ;-p
If the mouse button is held down for some time, it will likley cause a problem.
It's not "likely", rather its pretty dependable.
And pretty quick - a simple script does it in less than 10ms.
It seems to me that whatever is kicked-off by the mousedown event hogs
the one and only JS thread (in Firefox and IE at least), so the mouseup
event is qued and can't interup the process started by the mousedown.
To 'work', the script must come up for air to see if some other event
wants to do something, setTimeout (or maybe setInterval) seem to be the
only way to do that.
It may be better to use setTimeout onmousedown, then cancel it
onmouseup, e.g.:
Depending on what you want. At 13ms timeout, you can only execute it
once every 13ms, whereas with the recursion it happens as fast as the
processor can process the script.
If the minimum interval is 13ms (or whatever, I guess it's
implementation dependent) then that is as fast as you can do it. Other
choices are to either wait for a 'too much recursion' error or a 'this
script is taking too much time' message.
Maybe they suit the OP better :-)
--
Rob This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jerry O |
last post by:
Hi,
I am having trouble implemeting the OnMouseDown event in NN4.7 when
used on a Input of type image.
It works in Mozilla and N6.2
Is this a limitation or is there a workaround
Thanks,
|
by: Weston C |
last post by:
I'm trying to use onMouseDown to build a certain behavior into a
javascript application (see
http://groups.google.com/groups?q=Weston+onMouseDown+group:comp.lang.javascript&hl=en&lr=&ie=UTF-8&group=comp.lang.javascript&selm=3febb6e5%240%24201%2475868355%40news.frii.net&rnum=1
for the gory details, but essentially I want a pop-up menu to appear
when I
hold the mouse down on an image element for at least one second).
However, I'm finding...
|
by: Gary Mayor |
last post by:
Hi,
I'm trying to make it so when I click a image it prints out the image
again and a load of other stuff. So far i've got this far.
<html>
<head>
<script language="JavaScript" type="">
document.onmousedown = onmousedown;
function onmousedown(e)
{
|
by: sameth |
last post by:
I wrote a script that uses onmousedown and onmouseup in javascript that
works great in ie and firefox on windows2000. It looks as if the
pocketpc 2003 ie browser dosn't support onmousedown or onmouseup and
only such as onclick.
I need to be able to submit a form when the mouse is held down on a
button and submit a different form when the mouse is lifted up from the
button. could anyone tell me of anything I could substitute onmousedown...
|
by: stef |
last post by:
Hello:
I would like a process to continue as long as the mouse is held down on
a button and to stop as soon as it is released. Something ideally like
this:
"while (ButtonIsDown) {i+ = 1}"
I tried the following in the button tag:
onMouseDown = "isDown = true; while(isDown) {i+=1}"
| |
by: walkerfx |
last post by:
Hi All,
Is there a way to access the value assigned to onmousedown for an
object? I've been searching online but can only seem to find how it is
assigned via html. What I need to do is access the value (the script
string) in javascript.
For example, I'd like to try to do something like this:
function virtualClick(objectName) {
|
by: jon |
last post by:
Hello,
I'm trying to experiment with some javascript to do some custom
dragdrop handling. I wish to use the onMouseDown event to trigger the
start of my drag, and onMouseup for a potentential drop. I hope to
turn on the onmouseup only in onmousedown. And eventually go one step
further and incorporate onmousemove for a true drag workflow.
I'm running into a problem however, where after mousedown, mouseup will
not fire when I release...
|
by: NeilCarmichael |
last post by:
I am flummoxed, I'm relatively new to javascript and I can't get my
onmousedown onmouseup script to work.
simply, I want to fire one function when I click down on a graphic and
a second when I release.
I tried different combinations of onmousedown onmouseup and onclick
and putting them in div's img's and anchor's but I can't get it to
work, any ideas?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |