TextArea.setFocus not function as expected

83 views
Skip to first unread message

tong123123

unread,
Jun 22, 2012, 5:11:38 AM6/22/12
to google-we...@googlegroups.com
there is a Tree and a TextArea, when user click on the TreeItem, the TreeItem text will be copied to the TextArea, and I want the mouse cursor (focus) remain on the TextArea so when user type some text after click on the tree item, the text will be added in the TextArea.
I try to use ScheduledCommand but not work.

    dbField.addSelectionHandler(new SelectionHandler<TreeItem>(){
       public void onSelection(SelectionEvent<TreeItem> event){
            customSqlTextBox.setText(event.getSelectedItem().getText());
            Scheduler.get().scheduleDeferred(scheduleCmd);
       }
    });


private final ScheduledCommand scheduledCmd = new ScheduledCommand(){
   @Override
   public void execute(){
    customSqlTextBox.setFocus(true);
   }
};

 the result is very strange, after I click the treeitem, I see the cursor (insertion cursor) on the textarea in a very short time and then disappear, and when I type some text, the text will not be entered on the textarea.

what is the reason of this problem?
Reply all
Reply to author
Forward
0 new messages