VectorWatch / Developer-Platform

21 stars 6 forks source link

Add simple textfield input to stream config #26

Closed danmana closed 7 years ago

danmana commented 7 years ago

Sometimes the list of all possible input values is not known, so GridList or Autocomplete are not useful. For example: showing some personalized text, entering a username, a custom key etc.

Could you please add a simple textfield input method?

danmana commented 7 years ago

The workaround I'm using now is to have an autocomplete list filled with the search term on every keypress.

vectorWatch.on('config', function(event, response) {
    // your stream was just dragged onto a watch face
    logger.info('on config');

    var what = response.createAutocomplete('Foo');
    what.setAsYouType(1);
    what.setDynamic(true);

    response.send();
});

vectorWatch.on('options', function(event, response) {
    // dynamic options for a specific setting name was requested
    logger.info('on options');
    var settingName = event.getSettingName();
    var searchTerm = event.getSearchTerm();

    switch(settingName) {
        case 'Foo':
            response.addOption(searchTerm);
            break;
    }

    response.send();
});
RodgerLeblanc commented 7 years ago

You can do the same without returning anything in on options, you'll have basically what you need, a textfield input. `vectorWatch.on('options', function(event, response) {

// dynamic options for a specific setting name was requested

logger.info('on options');

}); `

danmana commented 7 years ago

@RodgerLeblanc thanks, that works

I tried this initially, but it looked like it didn't work, I guess that I didn't wait enough for my scheduler to kick in (unlike when testing in the browser, where it's instant)