New Widget

M

MartinRinehart

THIS WIDGET RUNS CORRECTLY IN OPERA. Nothing else. (See previous
post.)

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:

http://www.martinrinehart.com/examples/clicker.html

Constructive peer review of the code is most welcome.

Issues:
How to run in the other <canvas>-supporting browsers: Chrome, Firefox,
Safari
How to handle focus
How to position tic labels (how wide is "255"?)

Suggestions appreciated.
 
A

Aaron Gray

THIS WIDGET RUNS CORRECTLY IN OPERA. Nothing else. (See previous
post.)

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:

http://www.martinrinehart.com/examples/clicker.html

Constructive peer review of the code is most welcome.

Issues:
How to run in the other <canvas>-supporting browsers: Chrome, Firefox,
Safari
How to handle focus
How to position tic labels (how wide is "255"?)

Suggestions appreciated.

Works on Google Chrome except for cursor key strokes.

I would remove the pop up dialog, (its annoying ;)

Regards,

Aaron
 
D

David Mark

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.
How to handle focus

Focus of what?
How to position tic labels (how wide is "255"?)

What have you tried?
Suggestions appreciated.

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,122
Latest member
VinayKumarNevatia_
Top