moai/moai-dev — Issue #163: Changing text style attributes doesn't update the text.
Author: danadrew
Created: 2012-03-02 22:05:57+00:00
State: open
Labels: Bug

See sample in: samples / test / setstyle2

**Expected:**
Calling setFont, setSize, or setColor on a text style should immediately update the text that is using that style.
OR
Calling setStyle should update only the style that is inputted.

**Actual:**
Text is not always updated immediately when setFont, setSize, or setColor are called. setStyle must be called to update the style with changes when that happens. Calling setStyle on -any- style will update -all- of the styles.

**Repro Steps:**
1. Create a default style and textbox that uses only the default style.
2. Wait for some kind of user input before continuing.
3. Change the default style to some other values, notice that nothing changes.
4. Wait for user input before continuing.
5. Call setStyle to create an unused style (don't change the default), notice that the text updates to the changes made in step 3.

**Additional Info:**
In the sample, initially a text box is created that uses only the default text style, and the default text style is set to red, size 12, arial font. After pressing space bar once, it sets the style to size 24 and dwarves font, however it only acts on the style itself, ie. it doesn't call setStyle again, and no change appears. Pressing spacebar a second time will call setStyle to create the new style 'red' which is unused, and you will notice that at this time the text will update to use the modified style attributes.

There are two potential bugs here, depending on the intended functionality:

1. If you're not supposed to be required to call setStyle again in order to update the style (ie. simply calling setFont, setSize, or setColor should update the style), then the bug is that those functions aren't updating the style until setStyle is called for any style (even an unused one).
2. If you are supposed to be required to call setStyle again in order to update the style, then the bug is that calling setStyle on -any- style will update -all- of the styles. If this is the intended functionality, it should only update the style specified in setStyle. It would also mean that there's an additional bug, where changing the style immediately after calling setStyle (ie. without waiting for a spacebar input as in the sample), it will display the updated attributes instead of the attributes that were set before the setStyle function was called.

Either way, there is a bug here.