diff --git a/IPython/html/static/notebook/js/widgets/string.js b/IPython/html/static/notebook/js/widgets/string.js index 16af4bb..2e06f74 100644 --- a/IPython/html/static/notebook/js/widgets/string.js +++ b/IPython/html/static/notebook/js/widgets/string.js @@ -63,6 +63,14 @@ define(["notebook/js/widget"], function(widget_manager){ this.$textbox.val(this.model.get('value')); } + if (this.last_scroll_to_bottom == undefined) { + this.last_scroll_to_bottom = 0; + } + if (this.last_scroll_to_bottom < this.model.get('scroll_to_bottoms')) { + this.last_scroll_to_bottom < this.model.get('scroll_to_bottoms'); + this.$textbox.scrollTop(this.$textbox[0].scrollHeight); + } + var disabled = this.model.get('disabled'); this.$textbox.prop('disabled', disabled); diff --git a/IPython/html/widgets/widget_string.py b/IPython/html/widgets/widget_string.py index 2ddad4e..038625f 100644 --- a/IPython/html/widgets/widget_string.py +++ b/IPython/html/widgets/widget_string.py @@ -27,11 +27,12 @@ class StringWidget(Widget): default_view_name = Unicode('TextBoxView') # Keys - _keys = ['value', 'disabled', 'description', 'submits'] + _keys = ['value', 'disabled', 'description', 'submits', 'scroll_to_bottoms'] value = Unicode(help="String value") disabled = Bool(False, help="Enable or disable user changes") description = Unicode(help="Description of the value this widget represents") submits = Int(0, help="Used to capture and fire submission ") + scroll_to_bottoms = Int(0, help="Used to scroll a TextAreaView to the bottom") def __init__(self, **kwargs): @@ -39,6 +40,10 @@ class StringWidget(Widget): self._submission_callbacks = [] + def scroll_to_bottom(self): + self.scroll_to_bottoms += 1 + + def on_submit(self, callback, remove=False): """Register a callback to handle text submission (triggered when the user clicks enter).