datagrid: on closeeditor the accents are lost
Trevor DeVore
lists at mangomultimedia.com
Wed Feb 16 07:45:09 EST 2011
On Tue, Feb 15, 2011 at 5:30 PM, JosepM <jmyepes at mac.com> wrote:
>
> Using this:
>
> SetDataOfIndex the dgIndex of me, the dgColumn of me, unidecode(the
> unicodeText of pFieldEditor, "utf8")
>
> Don't work. Still losing the accents...
>
In order to confirm whether or not the data grid might be messing up the
data I made a test. I created a new data grid from, added 3 lines of text
and customized the row behavior as follows:
1) Changed FillInData to the following:
*on* FillInData pDataArray
*set* the unicodeText of field "Label" of me to uniencode(pDataArray["label
1"], "utf8")
*end* FillInData
2) Updated mouseDoubleUp so that UTF8 text is used as in your example. Note
that because you are passing 3 parameters to EditFieldText any edits made
will be stored in the data grid automatically.
*on* mouseDoubleUp pMouseBtnNum
*local* theKey
*if* pMouseBtnNum is 1 *then*
*if* the dgProps["allow editing"] of the dgControl of me *then*
*switch* the short name of the target
*case* "Label"
*put* "Label 1" into theKey
*set* the dgTemplateFieldEditor["utf8text"] of the dgControl
of me to unidecode(the unicodetext of field 1 of me,"utf8")
EditFieldText the long ID of the target, the dgIndex of me,
theKey
*break*
*end* *switch*
*end* *if*
*end* *if*
*pass* mouseDoubleUp
*end* mouseDoubleUp
I then edited the lines in the data grid, adding é as well as some accented
Turkish characters. All changes were successfully saved and displayed in the
data grid.
Next I tried adding a CloseFieldEditor handler that saves the UTF8 text to
the data grid:
*on* CloseFieldEditor pEditor
SetDataOfIndex the dgIndex of me, "Label 1", unidecode(the
unicodetext ofpEditor,
"utf8")
RefreshIndex the dgIndex of me
*end* CloseFieldEditor
Even though I shouldn't be setting the data in the data grid because I used
3 params with EditFieldText my tests still worked. They also worked if I
changed EditfieldText in mousedoubleUp so that only 1 parameter was passed
to it.
Based on these tests (let me know if you see anything wrong) I am inclined
to say that you still have a point in your code where you are not processing
the text as UTF8.
--
Trevor DeVore
Blue Mango Learning Systems
ScreenSteps: http://www.screensteps.com
LiveCode Resources for Developers: http://livecode.bluemangolearning.com
More information about the use-livecode
mailing list