THIS WIDGET RUNS CORRECTLY IN OPERA. Nothing else. (See previous
post.)
Yeah, I saw that one and its follow-up. Didn't know what to make of
it.
I've invented a new widget that I've named "clicker." It's like a
slider, but it hops immediately to the spot clicked. (See code
comments for how I stumbled into this.) It's here:
I hate to burst your bubble, but many sliders do that.
http://www.martinrinehart.com/examples/clicker.html
Constructive peer review of the code is most welcome.
I'm not holding out much hope here. The initial disclaimer is pretty
scary.
<body onload=init()>
Well, that is a good idea (but you need quotes around the attribute
value.) I have come to think that is a better idea than window.onload
(if you are writing a script for your own page.) I prefer to keep all
other script out of the markup (for the usual raasons), but that one
extra attribute hurts nothing and avoids the unneeded use of a non-
standard host object method.
Issues:
How to run in the other <canvas>-supporting browsers: Chrome, Firefox,
Safari
That's a pretty open-ended question.
Focus of what?
How to position tic labels (how wide is "255"?)
What have you tried?
Looking at a sample listener:
function click() {
var evt = window.event;
x_ = evt.pageX - clicker.left_;
clicker.repaint( x_ );
clicker.computeValueAt( x_ );
} // end of click()
You have made a simple mistake. The event property of the window
object is not standard. By coincidence, according to your claims, it
appears that Opera supports it to mimic IE. It likely does this so
that browser sniffing scripts will not exclude its users from rich
content that it is perfectly capable of rendering.
This listener should start like:
function click(evt) {
evt = evt || window.event;
Then you need a function that will return the mouse position relative
to some coordinates that are meaningful to your widget. I think there
is an example in the FAQ or FAQ notes that retrieves the document
coordinates. Certainly evt.pageX alone is insufficient.
Unfortunately, here you needed to make use of "unobtrusive
javascript."
<canvas id=clicker1 class=clicker
width=200 height=30
onclick=click()
onkeypress=keypress()
onmousewheel=wheel()
In other words, your click, keypress and wheel functions are not
listeners, so they will not receive an event object as their first
argument unless you pass it explicitly:
onclick-"click(event)"
And no, I don't recommend doing it like that.
And why would you use canvas for this at all? It seems like the worst
possible choice for a cross-browser slider solution.