@@ -267,11 +267,14 @@ mpl.figure.prototype._init_toolbar = function () {
267267 }
268268
269269 function on_mouseover_closure ( tooltip ) {
270- return function ( _event ) {
271- return fig . toolbar_button_onmouseover ( tooltip ) ;
270+ return function ( event ) {
271+ if ( ! event . currentTarget . disabled ) {
272+ return fig . toolbar_button_onmouseover ( tooltip ) ;
273+ }
272274 } ;
273275 }
274276
277+ fig . buttons = { } ;
275278 var buttonGroup = document . createElement ( 'div' ) ;
276279 buttonGroup . classList = 'mpl-button-group' ;
277280 for ( var toolbar_ind in mpl . toolbar_items ) {
@@ -290,7 +293,7 @@ mpl.figure.prototype._init_toolbar = function () {
290293 continue ;
291294 }
292295
293- var button = document . createElement ( 'button' ) ;
296+ var button = ( fig . buttons [ name ] = document . createElement ( 'button' ) ) ;
294297 button . classList = 'mpl-widget' ;
295298 button . setAttribute ( 'role' , 'button' ) ;
296299 button . setAttribute ( 'aria-disabled' , 'false' ) ;
@@ -423,6 +426,16 @@ mpl.figure.prototype.handle_image_mode = function (fig, msg) {
423426 fig . image_mode = msg [ 'mode' ] ;
424427} ;
425428
429+ mpl . figure . prototype . handle_history_buttons = function ( fig , msg ) {
430+ for ( var key in msg ) {
431+ if ( ! ( key in fig . buttons ) ) {
432+ continue ;
433+ }
434+ fig . buttons [ key ] . disabled = ! msg [ key ] ;
435+ fig . buttons [ key ] . setAttribute ( 'aria-disabled' , ! msg [ key ] ) ;
436+ }
437+ } ;
438+
426439mpl . figure . prototype . updated_canvas_event = function ( ) {
427440 // Called whenever the canvas gets updated.
428441 this . send_message ( 'ack' , { } ) ;
0 commit comments