Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

BJB Productions

macrumors 65816
Original poster
Nov 10, 2008
1,314
136
Hi,
Let me start out by saying I know I am a noob when it comes to dashcode. I'm just starting to get into programming, and I thought it would be fun to try and make my first widget.

So, basically, I have it setup so that when you click a button, a timer starts counting from zero. Each time you click the button, the counter resets, and starts over. Sounds easy, right? Haha, NOT for a NOOB. :rolleyes:

So what I have right is I assigned the button to "onclick" "start"
It then sends me to some code (see attached picture) that I cannot edit.


So..I'm really looking for someone who could help me out with the coding part. I'm also still am unsure as to how I should go about building my timer.

I know that is a lot to ask, but any help is much appreciated. Thanks for your time :)
 

Attachments

  • Screen shot 2010-04-22 at 5.00.35 PM.png
    Screen shot 2010-04-22 at 5.00.35 PM.png
    45.6 KB · Views: 169

flyingturtle

macrumors regular
Apr 7, 2010
116
2
That's odd that you can't edit your js file.

Hmm looking at your screenshot, it says you are editing AppleAnimator.js. You can click on arrow by the "AppleAnimator.js" (located right above your text editing pane" and select a different file to edit. Not sure if that'll help.

When I made some test widgets, I had to a edit "main.js" file. I just created a function for the "onclick" event for my button in the Inspector window, as described in Apple's Dashboard tutorial,. Clicking on the "arrow" icon next to my function name in the Inspector brought up main.js and then I just wrote some simple JavaScript.

As for coding a timer, just use setInterval for the timer.

A pretty good tutorial on making a timer widget in DashCode is here.
http://www.1995again.com/blog/2009/7/28/building-a-timer-in-dashcode-a-tutorial.html
 

BJB Productions

macrumors 65816
Original poster
Nov 10, 2008
1,314
136
That's odd that you can't edit your js file.

Hmm looking at your screenshot, it says you are editing AppleAnimator.js. You can click on arrow by the "AppleAnimator.js" (located right above your text editing pane" and select a different file to edit. Not sure if that'll help.

When I made some test widgets, I had to a edit "main.js" file. I just created a function for the "onclick" event for my button in the Inspector window, as described in Apple's Dashboard tutorial,. Clicking on the "arrow" icon next to my function name in the Inspector brought up main.js and then I just wrote some simple JavaScript.

As for coding a timer, just use setInterval for the timer.

A pretty good tutorial on making a timer widget in DashCode is here.
http://www.1995again.com/blog/2009/7/28/building-a-timer-in-dashcode-a-tutorial.html

Thank you very much for those links..I'll see what I can do. :)
 

BJB Productions

macrumors 65816
Original poster
Nov 10, 2008
1,314
136
I'm just baffled at why it won't let me edit the code..I can't add any code that is needed to complete a command. :confused:
 

flyingturtle

macrumors regular
Apr 7, 2010
116
2
If you follow that DashCode Widget Tutorial that I linked too earlier, are you able to edit your js file? In the case of the tutorial, it's the main.js file.

I'm not a DashCode expert, but it's interesting that you are editing AppleAnimator.js and specifically the AppleAnimator.prototype.start method (function). That indicates to me that it's a class file.

Are you sure you supposed to be editing the AppleAnimator class directly? You can override and extend the class, if you are really comfortable with OOP, but I gather that is not what you are trying to do, and if you are, normally you would do it in your own class definition, rather than directly edit the library itself.

That's probably why you can't edit it. It's a library file. Hmm I did a search and yeah. AppleAnimator is an Apple class library. You can use the AppleAnimator classes in your javascript as shown in the "Using Animation" guide.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.