0

I've got a text-edit in a window and the text edit fills the entire window. The problem is that after filling in text in the text edit, if you immediately close the window the text-edit won't save it's changes back to the field it is bound to.

It will save changes when you de-focus the text edit then click close, but not if you click close directly after typing in the text edit.

Is there a way to force the text-edit to store it's value when the window's close button is clicked?

Here is an example setup:

<button left="0" top="0" width="100" height="26" label="string">
    <action:when event="onClick">
        <action:call-widget-method method="win-test.show"/>
    </action:when>
</button>
<window left="0" top="0" width="250" height="350" name="win-test" visible="n">
    <text-edit left="0" top="0" right="0" bottom="0" field="var.test" multi-line="y" name="te-test"/>
</window>
Jim
  • 166
  • 6
  • That really feels like a bug in the widget's behavior. What if you try enabling "real-time-validation" attribute on the text-edit? Will that make any difference? – Vlad Sep 20 '12 at 03:35
  • 1
    Is there any reason that you can't have a button in the window which is used to close it with persistence? Killing the window feels like it has a connotation of cancelling what it was you were doing to me anyway (for all that it will happily persist if you blur the text edit elsewhere first). – Tristan Wilkinson Sep 20 '12 at 03:39
  • @Vlad, using real-time-validation does not change the behavior of the widget. – Jim Sep 24 '12 at 03:59

1 Answers1

0

Using the workaround suggested by Tristan.

Here's the updated example xml:

Added a button inside the window that closes it, and disabled the window widget's built in close button.

<button left="0" top="0" width="100" height="26" label="string">
    <action:when event="onClick">
        <action:call-widget-method method="win-test.show"/>
    </action:when>
</button>
<window left="0" top="0" width="250" height="350" name="win-test" visible="n" closable="n">
    <text-edit left="0" top="0" right="0" bottom="45" field="var.test" multi-line="y" name="te-test"/>
    <button right="10" bottom="7" width="80" height="32" label="Close" validate="n">
        <when event="onClick" xmlns="urn:aviarc:widget:com.aviarc.toronto.widget.core.action">
            <call-widget-method method="win-test.hide"/>
        </when>
    </button>
</window>
Jim
  • 166
  • 6