473,840 Members | 1,479 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to modify events (for ex. +ctrlKey)?

Hy;

I'm stucked in modifying events to make a multi-select select-input
being additive/subtractive only. Because I should offer a solution
similar to that select for DAUs (aka. MostIdioticUser ) I have to
make something else (checkboxes?).
It's not that want to fiddle around with events, but it seemed to be
the
most simply-plug-in-working-no-change-html-php solution.

Here is a fragment (the select and the plug-in code, I guess it's
explanatory for people fimilar with events, and it's not production-
code, it's only trying, trying, trying, ...):

<select size="10" name="uniqueMem ber[]" multiple="multi ple"
id="members">
<option>ABC</option>
<option>DEF</option>
<option>GHI</option>
<option>JKL</option>
<option>MNO</option>
<option>PQR</option>
</select>
<script type="text/javascript">
function cloneEventMouse (nevt, oevt) {
if (nevt.initMouse Event)
nevt.initMouseE vent(
oevt.bubbles, // PRBool canBubbleArg
oevt.cancelable , // PRBool cancelableArg
oevt.view, // nsIDOMAbstractV iew viewArg
oevt.detail, // PRInt32 detailArg
oevt.screenX, // PRInt32 screenXArg
oevt.screenY, // PRInt32 screenYArg
oevt.clientX, // PRInt32 clientXArg
oevt.clientY, // PRInt32 clientYArg
oevt.ctrlKey, // PRBool ctrlKeyArg
oevt.altKey, // PRBool altKeyArg
oevt.shiftKey, // PRBool shiftKeyArg
oevt.metaKey, // PRBool metkeyArg
oevt.button, // PRUint16 buttonArg
oevt.relatedTar get // nsIDOMEventTarg et relatedTargetAr g
);
else
for (var key in oevt)
try {
nevt[key] = oevt[key];
} catch(e) {}

nevt.cloned = true;
}

function modifyEvent(rec eiver, oevt, templ) {
var nevt = null;
var typeEvent = null;
var cloneEvent = null;

/* determine type of event-cloning */
switch (oevt.type) {
case 'mousedown':
case 'mouseover':
case 'mouseout':
case 'mouseup':
typeEvent = "MouseEvent s";
cloneEvent = cloneEventMouse ;
break;
default:
return null;
}

/* get a template */
if (!templ)
templ = new Array();

/* clone infos into template */
for (var key in oevt)
if (typeof oevt[key] != 'function' )
if (typeof templ[key] == 'undefined')
// try {
templ[key] = oevt[key];
// } catch(e) {}

/* clone the event */
if (document.creat eEvent && (nevt =
document.create Event(typeEvent ))) {
cloneEvent(nevt , templ);

receiver.dispat chEvent(nevt);
}
else if (document.creat eEventObject && (nevt =
document.create EventObject())) {
cloneEvent(nevt , templ);

receiver.fireEv ent("on" + oevt.type, nevt);
}

if (nevt) {
/* cancel the old event if possible */
// if (oevt.bubbles) {
if (oevt.stopPropa gation)
oevt.stopPropag ation();
oevt.cancelBubb le = true; //}
// if (oevt.cancelabl e)
oevt.returnValu e = false;
}

return nevt;
}

function tunnelEvent(obj , type, templ) {
if (obj.addEventLi stener)
obj.addEventLis tener(type,
function m(event) {
var cloned = (typeof event.cloned != 'undefined' &&
event.cloned);

/* modify if it's not allready */
if (!cloned)
modifyEvent(obj , event, templ);
return cloned;
}, true);
else
if (obj.attachEven t)
obj.attachEvent ('on' + type,
function m(event) {
var cloned = (typeof event.cloned != 'undefined' &&
event.cloned);

/* modify if it's not allready */
if (!cloned) {
modifyEvent(obj , event, templ);

/* this is disgusting:
*
* reason to do it this way:
* - internet explorer doesn't cancel events for inouts
* - internet explorer rejects events for disabled inputs
* - fireEvent is synchronous, the new event occurs before the
old event
*
* so I do this
* - create and send the new event with enabled field,
everything works fine
* - disable the input for the old event, after the new has
been processed
* - reactivate the input after old event rejected
(setTimeout(0) seem to need longer)
*/
obj.disabled = true;
setTimeout(func tion ar() {
obj.disabled = false;
}, 0);
}

return cloned;
});
}

tunnelEvent(doc ument.getElemen tById('members' ), 'mousedown', {
'ctrlKey' : true });
</script>

Thanks for any suggestions
Niels

Mar 1 '06 #1
2 1861
ni************* @seies.de wrote:
Hy;

I'm stucked in modifying events to make a multi-select select-input
being additive/subtractive only. Because I should offer a solution
similar to that select for DAUs (aka. MostIdioticUser ) I have to
make something else (checkboxes?).
It's not that want to fiddle around with events, but it seemed to be
the
most simply-plug-in-working-no-change-html-php solution.

Here is a fragment (the select and the plug-in code, I guess it's
explanatory for people fimilar with events, and it's not production-
code, it's only trying, trying, trying, ...):


Your code looks like a rather horrible kludge, can you explain what you
are trying to achieve? Modifying standard browser behaviour to suit a
small set of users is nearly always counter-productive.

Un-obtrusive on-screen help will usually solve the problem far more
effectively. Where possible, provide a few moments of instruction to
show users how to use a multiple-select element.

Having learned to use the standard behaviour, your users will now be
equipped to use any multiple-select anywhere, even in applications other
than a browser (provided someone hasn't mucked-around with the UI). :-)

[...]
--
Rob
Mar 2 '06 #2
> Your code looks like a rather horrible kludge, can you explain what you
are trying to achieve?
I try to do

onmousedown="ev ent.ctrlKey = true; return true;"

but I'm not allowed to do so with the IE/W3C-model it seems.
So I tried to make cloneEventWithM odifications().
Modifying standard browser behaviour to suit a
small set of users is nearly always counter-productive.
Sadly I'm not living in a world were people want to _learn_ something,
I'm
living in a world were people are not even able to read titles like
"Document-Tree" within a defined framework: 'Where am I?'. (BTW:
world means: El Salvador)
Un-obtrusive on-screen help will usually solve the problem far more
effectively. Where possible, provide a few moments of instruction to
show users how to use a multiple-select element.

Having learned to use the standard behaviour, your users will now be
equipped to use any multiple-select anywhere, even in applications other
than a browser (provided someone hasn't mucked-around with the UI). :-)

[...]
I also suffer from programmation-illness, classification,
encapsulation,
logics etc., so I have severe down-grade problems. I thought the
multiple
select is soooo nice. :) But my Chief is too DAU, in everything, so I'm
fighting clean concept against clean mind, everyday. 8´^[

Okay, enough cried out, thanks for the response, you don't maybe have
....
another ... idea? *duck*
Rob


Ciao
Niels

Mar 2 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
31309
by: oeyvind toft | last post by:
How do I capture the ctrl keypress? Is it possible for js to intercept the ctrl-n combination and prevent the creation of a new IE window?? (Have 3 huge books on js and none of them mention this subject) Oeyvind
10
3429
by: Hiroshi Ochi | last post by:
I keep getting 'member not found' error if I try to do the below command: // window.event.ctrlKey = false; // assigning value to property // Is it not allowed to change the window.event.ctrlKey value? But according to the reference in http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/properties/ctrlkey.asp , the ctrlKey property is read/write in IE 5 and later?
1
9329
by: Loony | last post by:
I want to use a ctrlKey event in my script! I have a code like this: function hiLite(imgDocID, imgObjName) { document.images.src = eval(imgObjName + ".src") } function KeyDown() { Key1=event.ctrlKey //JavaScript shows this event is not defined Key=event.keyCode
6
2766
by: pierre.bru | last post by:
hi, I encounter troubles with frames :( witht he folowing script in the _top page function walk(_frames) { for(var i=0; i<_frames.length; i++) { var frame = _frames; alert(frame.name);
3
2494
by: MilanB | last post by:
Hello I want to add some script code to every page on my application when page is about to send to client. I found some events that maybe can be used in this case (example: PreSendRequestContent). Any suggestion or in best way example how to do this. Thanks
5
4483
by: Martin Bischoff | last post by:
Hi, is it possible to modify the values of a SqlDataSource's select parameters in the code behind before the select command is executed? Example: I have an SqlDataSource with a ControlParameter <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:XYZ %>"
1
2484
by: mark4asp | last post by:
<!-- // How to detect the rendering mode which the browser is currently in (works for IE6). // Ctrl+Shift+s displays indicates whether the browser is in quirks or standards mode. // Detect keypress var captureKeys = function(ev) { ev = ev || window.event; // gets the event in ie or ns kCode = ev.keyCode || ev.which; // gets the keycode in ie or ns
1
1951
by: sergioabreu | last post by:
I saw a post about this issue, but it seemed to be closed. I needed a code that allowed to handle click + ctrl in a form object such as a textfield. In order to work also on IE, I wrote the textfield onclick property like this onclick="function(event){ if( event.ctrlKey) this.select()}" and ... for Firefox, I wrote this piece of code inside a script element: function clickPlus(){ try
2
2257
by: creative1 | last post by:
I get following error on page : Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\desiorb\411.php:9) in C:\xampp\htdocs\desiorb\411.php on line 21 when I set a cookie on first page. Please help me fix it. here is code fot both pages 411.php <html> <body> <form action="411process.php" method="post"> Email adddress: <input type="text" name="email" /> Cell #: <input type="text" name="cell" />
0
9856
marktang
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...
0
10916
Oralloy
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...
1
10657
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9436
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7836
isladogs
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...
0
7022
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();...
0
5684
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...
0
5872
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4071
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.