Closed Bug 278272 Opened 20 years ago Closed 19 years ago

No event for menu paste?

Categories

(SeaMonkey :: General, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED EXPIRED

People

(Reporter: matthew, Unassigned)

References

Details

Attached is some basic html that has a input field and another field with a
counter in it that counts down as a char is added to the field. On any browser I
have tested this works fine  with one exception. Using the menu paste to add
text into the text field. If you add text to this field using the menu paste
command no event ever triggers and so the counter never gets updated. I have
searched for possible events to capture the menu paste but so far have not found
anything.

If I have missed some special feature that allows this to work please let me
know but so far I have not found a way for me to take some action based on a
menu driven paste event.

Thanks
Matthew
matthew@mcgillis.org

<html>
<head>
<script type="text/javascript">
function textCounter(form, field, countfield)
{
    f = form;

    var maxlimit = '160';
    var from=0;

    if (f.from.value.length > 0)
        from = f.from.value.length + 4 + 1; // 1 is for '\n'

    var totalMsg = from;

    if (totalMsg > maxlimit)
    {
       var overflow = totalMsg - maxlimit;
       var backspace = field.value.length - overflow;
       if (field.value.length > 0 && backspace < 0)
       {
          backspace = backspace * -1;
          if (field.value.length < backspace)
             overflow = field.value.length;
          else
             overflow = backspace;
       }
       else if (field.value.length == 0 && backspace < 0)
          overflow = 0;

       field.value = field.value.substring(0, field.value.length-overflow);
    }
    else
       countfield.value = maxlimit - totalMsg;
} // textCounter()
</script>
</head>
<body>
<form>
<input type="text" name="from" 
onchange="textCounter(this.form, this.form.from, this.form.charCount);"
onkeydown="textCounter(this.form, this.form.from, this.form.charCount);"
onkeyup="textCounter(this.form, this.form.from, this.form.charCount);">
<input type=text name="charCount" size="3" value=160 readonly>
</form>
</body>
</html>
Adding oninput="textCounter(this.form, this.form.from, this.form.charCount);"
should work for your form, see http://www.highdots.com/forums/thread70634.html.
Related to/duplicate of bug 280683? 
Depends on: 280683
Confirmed Mozilla/5.0 (Windows; U; Windows NT 5.0; en-GB; rv:1.8b2) Gecko/20050318

It is related in a way to bug #280683, but shouldn't this trigger onChange
regardless? The content of the text box is clearly changing.
>Adding oninput="textCounter(this.form, this.form.from, this.form.charCount);"
>should work for your form, see http://www.highdots.com/forums/thread70634.html.
I can confirm that this menu paste event now work only if I add that "oninput"
event to the script.  Otherwise it wouldn't work without it.  

The "onpaste" event is disabled in Gecko browsers due to security reason as
stated on the comment at
http://www.telerik.com/Default.aspx?PageId=2202&b119Y=tqsX , as to prevent the
executable script from occuring.  But I could not find the documentation at
mozilla.org about the use of "onpaste" event.

Reporter: If your issue is about "onpaste" event then can you please resolve
this bug to be a duplicate of bug #280683.  If your issue is about "oninput"
then please resolve it as "Work For Me" once you added the "oninput" event.

No need to change this bug status to "New".
> but shouldn't this trigger onChange regardless?

It does, but when the textbox loses focus, not when the text is inserted. Which
is correct.
This is an automated message, with ID "auto-resolve01".

This bug has had no comments for a long time. Statistically, we have found that
bug reports that have not been confirmed by a second user after three months are
highly unlikely to be the source of a fix to the code.

While your input is very important to us, our resources are limited and so we
are asking for your help in focussing our efforts. If you can still reproduce
this problem in the latest version of the product (see below for how to obtain a
copy) or, for feature requests, if it's not present in the latest version and
you still believe we should implement it, please visit the URL of this bug
(given at the top of this mail) and add a comment to that effect, giving more
reproduction information if you have it.

If it is not a problem any longer, you need take no action. If this bug is not
changed in any way in the next two weeks, it will be automatically resolved.
Thank you for your help in this matter.

The latest beta releases can be obtained from:
Firefox:     http://www.mozilla.org/projects/firefox/
Thunderbird: http://www.mozilla.org/products/thunderbird/releases/1.5beta1.html
Seamonkey:   http://www.mozilla.org/projects/seamonkey/
This bug has been automatically resolved after a period of inactivity (see above
comment). If anyone thinks this is incorrect, they should feel free to reopen it.
Status: UNCONFIRMED → RESOLVED
Closed: 19 years ago
Resolution: --- → EXPIRED
You need to log in before you can comment on or make changes to this bug.