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?
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;