Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

  • mathias
    replied
    Hmm. I can't get this call to have any effect. I made a small method i call whenever i put focus on a formitem:

    Code:
    private void checkSelectBeginning(FormItem item){
            if(item instanceof DateItem){
                GWT.log("is dateitem, setting selectionrange to 0,0 : " + ((DateItem) item).getUseTextField());
                ((DateItem)item).setSelectionRange(0,0);
            }else if(item instanceof TextItem){
                ((TextItem)item).setSelectionRange(0,0);
                GWT.log("is textitem, setting selectionrange to 0,0" + ((DateItem) item).getUseTextField());
            }
        }
    I do get the printout:
    is dateitem, setting selectionrange to 0,0 : true
    So the object seems to be valid? However, the caret stays at the end of the formitem. Any suggestions?

    Leave a comment:


  • mathias
    replied
    Ah - i did not find this because it's not in FormItem. This means that i somehow have to check manually what type it is and cast it to the respective class if i want to change it. Would have loved for it to be in FormItem instead and not do anything for SelectItems :)

    Anyway - thanks!

    Leave a comment:


  • Isomorphic
    replied
    Yes, you can call setSelectionRange(0, 0) on your item

    Leave a comment:


  • Is it possible to manually move caret in a FormItem?

    In our app, we have a function where forms enter and exit "editmode" i.e. it can be seen when the form starts to be editable. When that happens we put focus on one specific item in the form.

    All this works, but if the formitem is not empty (i.e we're editing rather then creating a new item), the caret appears at the end of the text. It would be better if the caret was at the start of the formitem (a dateitem). So that you can just start typing.

    Is this at all possible?
Working...
X