It is possible to move the text cursor in TextItem?
The textBoxStyle is changed, after that the show() function is called, the cursor moved to beginning, how to avoid this or move the cursor?
Here is the sample code:
_constructor: "TextItem",
....
changed: function(form, item, value)
{
if (value && value.length > 0)
{
changeStyle(this, "textItem");
}
else
{
changeStyle(this, "myTextItem");
}
}
...
function changeStyle(obj, style) {
...
obj.textBoxStyle = style;
obj.show();
...
}
Thanks,
oadrian
Hi oadrian,
Instead of calling show(), call formItem.updateState(). This isn’t currently documented, but will be.
Hi Oadrian
Just a quick follow up - the ‘updateState()’ solution is still appropriate (and more efficient than your original code), but there actually is code in place to prevent this issue, and it appears to be working in 6.5.1 in our tests.
Our test case was as follows - copy and paste this code:
isc.DynamicForm.create({
items:[
{
_constructor: "TextItem",
changed: function(form, item, value)
{
if (value && value.length >1)
{
changeStyle(this, "textItem");
}
else
{
changeStyle(this, "myTextItem");
}
}
}
]
});
window.changeStyle = function changeStyle(obj, style) {
obj.textBoxStyle = style;
obj.show();
}
into the Form Layout / Titles example in the feature explorer (here: http://localhost:8080/isomorphic/system/reference/SmartClient_Explorer.html#formLayoutTitles), hit “try it” and type in the field. The style change will occur between 1 and 2 characters in the field, and it appears that the text insertion point is remaining at the end of field, as expected while you’re typing.
We aren’t reproducing the issue you describe. Can we just double check
- which browser are you using?
- which version of SmartClient are you using?
- are you seeing the issue with this test code?
Thanks
Isomorphic Software
Hi,
I tested my original code whit ‘updateState()’, but if I made changes very fast, sometimes doesn’t work. (type - delete - re-type).
ChangeStyle / dynamicForm, was declared in different files (library.js /details.js), so I moved changeStyle function to details.js, it seems that this resolved my problem.
More details :
Browser: IE 7 (Version 7.0.5730.13)
SmartClient: 6.5.1
Test case:
-with TextItem works fine;
-with TextAreaItem doesn’t work;
Ah - TextAreaItem vs TextItem makes sense - this is a known limitation with redrawing (which is what your “show()” call would ultimately do) in SmartClient 6.5x in IE.
We’ve got a fix for this issue as part of the 7.0 release.
It’s not clear to us why declaring your changeStyle method in a different file from the rest of your application logic would make updateState() sometimes fail when typing rapidly. If this problem resurfaces let us know and we’ll take a deeper look
Thanks
Isomorphic Software