bootstrap-markdown icon indicating copy to clipboard operation
bootstrap-markdown copied to clipboard

why put the cursor to the end when press tab?

Open Gwill opened this issue 11 years ago • 2 comments

The source code like this,

        case 9: // tab
          var nextTab
          if (nextTab = this.getNextTab(),nextTab != null) {
            // Get the nextTab if exists
            var that = this
            setTimeout(function(){
              that.setSelection(nextTab.start,nextTab.end)
            },500)

            blocked = true
          } else {
            // The next tab memory contains nothing...
            // check the cursor position to determine tab action
            var cursor = this.getSelection()

            if (cursor.start == cursor.end && cursor.end == this.getContent().length) {
              // The cursor already reach the end of the content
              blocked = false

            } else {
              // Put the cursor to the end
              this.setSelection(this.getContent().length,this.getContent().length)

              blocked = true
            }
          }

Gwill avatar Nov 04 '14 18:11 Gwill

There are some case whereas the editor instance need to go backward, eg : when you select an image. The editor will allow you to rewrite the image title/tag, then after there is no next tab in its memory, the editor will put the cursor at the end on the line. Thats the story behind this behaviour, and i think its pretty sensible to have it as default.

toopay avatar Jan 15 '15 13:01 toopay

I believe this is having another, unexpected, issue.

We use your library on our software, and we have had reports of the cursor being set to the end of the text field (not the end of the line) when alt-tabbing between windows, when using Windows.

If you are using a Mac, and alt-tab between windows, or even just press tab in the textarea, the tab is not recognised as a key press on the field and so the same does not occur (this is a good thing).

JRawly avatar Nov 27 '17 10:11 JRawly