By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,848 Members | 3,202 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,848 IT Pros & Developers. It's quick & easy.

New Widget

P: n/a
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.
Oct 24 '08 #1
Share this Question
Share on Google+
5 Replies


P: n/a
<Ma************@gmail.comwrote in message
news:35**********************************@m32g2000 hsf.googlegroups.com...
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
Oct 25 '08 #2

P: n/a
Aaron Gray wrote:
I would remove the pop up dialog, (its annoying ;)
Yup. Debugging stuff. Gone.
Oct 26 '08 #3

P: n/a
Aaron Gray wrote:
Works on Google Chrome except for cursor key strokes.
Really? I don't get mouse wheel in Chrome.
I would remove the pop up dialog, (its annoying ;)
Agreed. Done. (That was debugging stuff.)

Martin
Oct 26 '08 #4

P: n/a
Aaron Gray wrote:
Works on Google Chrome except for cursor key strokes.
Really? I don't get mouse wheel.
I would remove the pop up dialog, (its annoying ;)
Done.

Oct 26 '08 #5

P: n/a
On Oct 24, 1:38*pm, MartinRineh...@gmail.com wrote:
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.
Oct 26 '08 #6

This discussion thread is closed

Replies have been disabled for this discussion.