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="uniqueMember[]" multiple="multiple"
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.initMouseEvent)
nevt.initMouseEvent(
oevt.bubbles, // PRBool canBubbleArg
oevt.cancelable, // PRBool cancelableArg
oevt.view, // nsIDOMAbstractView 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.relatedTarget // nsIDOMEventTarget relatedTargetArg
);
else
for (var key in oevt)
try {
nevt[key] = oevt[key];
} catch(e) {}
nevt.cloned = true;
}
function modifyEvent(receiver, 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 = "MouseEvents";
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.createEvent && (nevt =
document.createEvent(typeEvent))) {
cloneEvent(nevt, templ);
receiver.dispatchEvent(nevt);
}
else if (document.createEventObject && (nevt =
document.createEventObject())) {
cloneEvent(nevt, templ);
receiver.fireEvent("on" + oevt.type, nevt);
}
if (nevt) {
/* cancel the old event if possible */
// if (oevt.bubbles) {
if (oevt.stopPropagation)
oevt.stopPropagation();
oevt.cancelBubble = true; //}
// if (oevt.cancelable)
oevt.returnValue = false;
}
return nevt;
}
function tunnelEvent(obj, type, templ) {
if (obj.addEventListener)
obj.addEventListener(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.attachEvent)
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(function ar() {
obj.disabled = false;
}, 0);
}
return cloned;
});
}
tunnelEvent(document.getElementById('members'), 'mousedown', {
'ctrlKey' : true });
</script>
Thanks for any suggestions
Niels 2 1830 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
> Your code looks like a rather horrible kludge, can you explain what you are trying to achieve?
I try to do
onmousedown="event.ctrlKey = true; return true;"
but I'm not allowed to do so with the IE/W3C-model it seems.
So I tried to make cloneEventWithModifications().
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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...
|
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() {...
|
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);
|
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:...
|
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...
|
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...
|
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...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |