5 Replies Latest reply: Jun 18, 2009 1:26 PM by Israel Brewster
Israel Brewster Level 1 Level 1 (15 points)
Ok, I feel stupid for having to ask this, but how on earth can you change the label of a button in a dashboard widget? I have tried setting the label, innerText and textElement properties, as well as getting the innerHTML property and changing the proper (I think) portion of that, all with no luck. Either nothing seems to happen, or the button is replaced with static text. In the case of replacing the innerHTML property, it actually retained the button appearance, but was no longer clickable. What am I missing here? The next challenge after that gets worked out is to get it hold the text for two seconds and then change back, but I haven't started looking into the documentation for that yet Thanks.

2.4 GHz 20" iMac C2D, Mac OS X (10.5.4), 3 GB RAM
  • 1. Re: Dashboard-change button label
    K T Level 7 Level 7 (23,700 points)
    Does the 'Event Label' text ring a bell?

    Have you seen/does this Widget tutorial help?
  • 2. Re: Dashboard-change button label
    Israel Brewster Level 1 Level 1 (15 points)
    Yep, been through that tutorial, and that works fine for static labels- in fact, I'm using that method in a couple of places. Unfortunately, applying that approach to the button is one of the things that replaces the button with static text :-P
  • 3. Re: Dashboard-change button label
    K T Level 7 Level 7 (23,700 points)
    Can you make/apply an image of your own w/text already on it?
  • 4. Re: Dashboard-change button label
    Israel Brewster Level 1 Level 1 (15 points)
    Probably, but I need a button, and trying to do some kind of overlay seems overly complicated. I could do a separate label, which would work easily enough, but that just feels kludgy, so I'd rather not. I would think it should be fairly easy just to change the button text. At least, it has been in every other type of application I have made. I have to think I'm just missing something here. Maybe I'll figure it out tomorrow - for now, to bed
  • 5. Re: Dashboard-change button label
    Israel Brewster Level 1 Level 1 (15 points)
    Ah-ha! Found it! It is the innerText property, but it needs to be set not on the button returned by getElementById, but rather on the textElement of the object of the button! I.e., rather than the following code:
    var button=document.getElementByID("buttonName");
    button.innerText="Whatever";

    I need this:
    var button=document.getElementByID("buttonName");
    button.object.textElement.innerText="Whatever";

    The first one changes the button to just plain text, the second one actually changes the text on the button. Course, that doesn't explain why it was so difficult to track that down... I can't imagine that I'm the first person who wanted to change button text!