Switch Input on Tabstop (atom-smart-templates)

Hey there,

I stumbled across this package: https://atom.io/packages/atom-smart-template

What it does: Generate files from templates.

So far I forked the repo and changed some stuff like creating multiple files at once. Now the last perk to upgrade it would be to “tabstop” through the inputs like on any other form.

I added 'tab': 'atom-smart-template:next-tabindex' to the atom-smart-template.cson and

@on 'atom-smart-template:next-tabindex', =>
      console.log(@panel)

to select-view.coffee

The trigger on the tab-key works but I just don’t get how to set the next input active on tabstop hit. I tried to add tabindexes to the TextEditorView() / the parent of the TextEditorView() but with no luck.

So far I did not found something like getActiveView() or setFocusedView() in the docs.

Any hints? :confused:

Thanks in advance!

I’m not quite sure what you want, but if you want to change the active tab you should look into the workspace API, an instance of which is atom.workspace. To cycle tabs, you would want to get the active pane, and use the various item methods like activateNextItem.

^ I think. I haven’t tried it.

Thanks, I’ll have a look.

To be more specific:

58

that’s the input form when I add a new template. In this example there are two inputs “of type” TextEditorView()

@content
@content: (itemPath, template) ->
    @div class: 'overlay from-top', =>
      @h4 'New files by template: ' + template.name

      for param in (template.params ? [])
        @label param
        @subview param + 'Editor', new TextEditorView(mini: true)

      @button outlet: 'createButton', class: 'btn', 'Create'
      @button outlet: 'cancelButton', class: 'btn', 'Cancel'

So I want to add a “tab” support like most people are used to from “normal forms”.

That looks like a custom element; I think that should work like any other HTML. The workspace advise would only apply to changing the active file tab.

I freakin got it. The only change neccessary was one line and a helper var:

@count = 1
      for param in (template.params ? [])
        @label param
        @subview param + 'Editor', new TextEditorView(mini: true, tabIndex: @count,  attributes:{tabindex:@count})
        @count++

Thanks again for the “thinking-hints” :slight_smile: