views:

65

answers:

1

I've written a Sidebar gadget in Windows 7, and added a g:textObject, and later on change the value through variable.value.

But when run in Windows Vista, the text seems to compress itself strangely.

Is there anything wrong with this code?

var clock = document.getElementById("background").addTextObject("Time", "Nyala", 18, "white", 110, 500);
//This correctly displays the word 'Time' in the proper font.

clock.value = clock.value+"s";
//This causes the text to become "Times" but shrink.
//appending more sporadically causes the textObject to shrink as well.

Is using the .value the wrong way to do this?

+1  A: 

Changing the text string doesn't update the width or height of the g:text object. It's a known issue that probably won't be fixed for compatibility purposes. You have to manually reset the width and height changing the value:

var clock = document.getElementById("background")
    .addTextObject("Time", "Nyala", 18, "white", 110, 500);

// Set the new value and reset the width and height by setting them to 0
clock.value  = clock.value+"s";  
clock.width  = 0;
clock.height = 0;
Andy E
Thanks, I'll try that out! By the way, is all this documented anywhere? I couldn't get google to point me to the right place in msdn, where I assume it should be..
Vanwaril
A lot of bugs and, where applicable, their respective workarounds can be found at http://www.aeroxp.org/board/index.php?showtopic=7318. The list hasn't been updated in a while, however. I think, from my own testing, around 18 of those bugs are fixed in Windows 7.
Andy E